im使用Native base作为react应用程序,问题是TextArea组件上的_focus={{}}不起作用。我把代码放在这里,如果有人知道如何让它工作,我将不胜感激。谢谢
import React from 'react';
import { TextArea } from 'native-base';
function TextAreaComponent({
height = '20',
placeholder,
width = '75%',
maxWidth = '300',
isInvalid = false,
isDisabled = false,
backgroundColor = '#F4F4F6',
borderColor = '#E1E0E6',
borderWidth = '1px',
color = '#73737D',
fontSize = '14px',
numberOfLines = '4',
}) {
return (
<TextArea
height={height}
placeholder={placeholder}
width={width}
maxWidth={maxWidth}
isInvalid={isInvalid}
isDisabled={isDisabled}
backgroundColor={backgroundColor}
borderColor={borderColor}
color={color}
borderWidth={borderWidth}
fontSize={fontSize}
numberOfLines={numberOfLines}
_focus={{ borderColor: 'white' }}
// _focus={{ borderColor: '#fff' }} //? focus here left to implement.
/>
);
}
export default TextAreaComponent;
我对代码库不太熟悉,但我认为_focus
道具与react native中Input
组件的onFocus
相同。
以下是如何使用onFocus
:的示例
<Input
...
onFocus={() => {
updateBorderColor({ borderColor: 'white' });
}}
/>
也许试着为_focus
遵循同样的逻辑?