And then use the spread operator on your components: <TextField {...formikProps('fieldName')}/>
The initial value is required to tell React it's a controlled component. The above function only works for TextFields (Checkboxes, etc, don't directly support helperText so it would need to be modified).
I wrote a small helper to reduce the boilerplate:
And then use the spread operator on your components:
<TextField {...formikProps('fieldName')}/>
The initial value is required to tell React it's a controlled component. The above function only works for TextFields (Checkboxes, etc, don't directly support helperText so it would need to be modified).
Thanks!!!!
I'd like to add a simple enhancement by adding
error: touched[name] && Boolean(errors[name])
, this will remove an error from the console