Formik: Checkbox initial values and form clear

Created on 17 Oct 2017  路  5Comments  路  Source: formium/formik

I'm having issues while setting the checkboxes inititial values as true, and when resetting the form setting them back to their initial values:
https://codesandbox.io/s/l98zymm147

Is there something missing?

Thanks

/edit: digging a little bit more, moved the input to a component to test it a little bit more, and found that the onChange event is not firing. May be related?

Most helpful comment

Yeah, this is fine if you're using basic input elements, but it seems weird that doesn't just figure this out automatically. Could we reopen this?

All 5 comments

In React, checkboxes don't use a value prop, but instead require checked. https://reactjs.org/docs/forms.html#handling-multiple-inputs

So just set checked={values.check} in your code sandbox

I also noticed this behavior. Would anyone be open to a change where "checked" was set instead of "value" if the type is "checkbox"?

Yeah, this is fine if you're using basic input elements, but it seems weird that doesn't just figure this out automatically. Could we reopen this?

Cheers jaredpalmer. It's useful to know values is accessible:

checked={values.check}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dearcodes picture dearcodes  路  3Comments

green-pickle picture green-pickle  路  3Comments

jeffbski picture jeffbski  路  3Comments

Jucesr picture Jucesr  路  3Comments

sibelius picture sibelius  路  3Comments