【发布时间】:2023-02-19 19:46:57
【问题描述】:
我在 React Native 中制作了一个可重用的文本输入组件,但是当我尝试访问文本值时,它为我提供了合成事件对象,然后是文本值,我无法定位文本值。我知道这可能是重复的,但我尝试了很多方法但它不起作用。这是我的代码 sn-p。
/**Imported Component **/
<InputField
placeholder="Disabilities"
defaultValue={values.associatedDisabilities.toString()}
onChange={(value) => console.log(value)}
/>
/**Reusable Component **/
<TextInput
style={[
styles.textInput,
props.style,
{ color: theme.colors.mainForeground },
]}
onChangeText={props.onChange}
defaultValue = {props.defaultValue}
value={props.value}
onBlur={props.onBlur}
{...props}
placeholderTextColor={
currentTheme === ThemeTypes.LIGHT
? theme.colors.secondaryText
: theme.colors.mainForeground
}
editable={props.editable}
selectTextOnFocus={props.editable}
/>
【问题讨论】: