【发布时间】:2021-06-11 09:43:57
【问题描述】:
//下面的代码给出了一个错误:'onChange is not a function'。 我渲染 TextInput 并且它是动态的,这意味着我正在使用 react-hook-form 创建动态表单,但 onChange 不起作用。请帮助!
<Controller
control={control}
name={fields.field_name[index]}
rules={{ required: true }}
render={({ onChange, value }) => (
<TextInput
placeholder={' ' + fieldName}
editable={fields.context_type == 'Location' ? false : true}
keyboardType={fields.context_type == 'Decimal' ? 'decimal-pad' : 'default'}
value={fields.context_type == 'Location' ? machineLocation : value}
onChangeText={(value) => onChange(value)}
></TextInput>
)}
/>
【问题讨论】:
-
Controller是什么? -
我认为你需要
field: { onChange }作为你的渲染道具
标签: javascript reactjs react-native react-hooks