Reputation: 2005
I try to use formik with autogenerated forms. But when there are checkbox's I get an warning:
Warning: A component is changing an uncontrolled input of type checkbox to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa).
when touching them. For other fields in may be solved with an initial value for formilk component. But checkboxes shouldn't have initial value. How it may be fixed?
Upvotes: 1
Views: 2810
Reputation: 311
A few of things:
name =
prop for the Fieldchecked
is set to a boolean--NOT a "truthy" value (like a string, number, or object). So instead of doing this: checked={someArray.find(x....)}
do this:{!!someArray.find(x....)}
Upvotes: 1
Reputation: 2005
Well, it looks like you should have initialValue with a name of every field and set false/true for every input:checkbox.
Upvotes: 5