Formik: Formik called `handleChange`, but you forgot to pass an `id` or `name` attribute to your input:undefined

Created on 12 Nov 2019  路  1Comment  路  Source: formium/formik

I started using formik in react-native and a warning is shown to me whenever I try typing something.

const CustomInputComponent = ({ field, form: { touched, errors, handleBlur, handleChange, values }, ...props }) => { return ( <View style={Styles.w100}> <Input {...field} {...props} onBlur={handleBlur(field.name)} onChangeText={handleChange(field.name)} value={values[field.name]} /> </View> ) }

and the field

<Field placeholder='Password' name='password' icon='key' component={CustomInputComponent} />

stale

Most helpful comment

I had this problem as well. It turned out thet TextInput didn't like to get all of the field properties. I think your code will work if you remove {...field} from your Input properties.

I didn't dig any further, so I don't know the actual reason to the problem. Anyway, I don't think there are any important stuff in the field variable that you'd want to send to your Input (apart from "name", which you access via field.name anyway). It also has value, but you are using values[field.name] anyway.

>All comments

I had this problem as well. It turned out thet TextInput didn't like to get all of the field properties. I think your code will work if you remove {...field} from your Input properties.

I didn't dig any further, so I don't know the actual reason to the problem. Anyway, I don't think there are any important stuff in the field variable that you'd want to send to your Input (apart from "name", which you access via field.name anyway). It also has value, but you are using values[field.name] anyway.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dearcodes picture dearcodes  路  3Comments

jordantrainor picture jordantrainor  路  3Comments

pmonty picture pmonty  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

green-pickle picture green-pickle  路  3Comments