You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating to React 19 creating a form with a checkbox and not providing initial values will cause the checkbox to go into multi mode and change from using true/false values to using ['on']/[] as values.
Current result on submit: [{"myCheckbox":["on"]},{}]
Expected behavior
Using same code with React 18.3.1 the result is this: [{"myCheckbox":true},{}]
As @mmussmann beat me to it, I’m just going to add the issue I intended to raise (see below) as a comment here. Perhaps the workaround works for others as well.
Checkbox Behavior Change with React v19
Bug report
When the initial value is undefined using a field with type checkbox (through useField), the field’s behavior is unexpectedly different with React v19.
Bug report
Current Behavior
After updating to React 19 creating a form with a checkbox and not providing initial values will cause the checkbox to go into multi mode and change from using true/false values to using ['on']/[] as values.
Current result on submit: [{"myCheckbox":["on"]},{}]
Expected behavior
Using same code with React 18.3.1 the result is this: [{"myCheckbox":true},{}]
Reproducible example
How to reproduce in examples:
Example with React 19: https://codesandbox.io/p/sandbox/formik-checkbox-bug-reproduction-96p8gs
Example with React 18: https://codesandbox.io/p/sandbox/yc6ss2
Suggested solution(s)
I have not looked into the Formik code so I don't have a suggestion for a code fix.
Additional context
N/A
Your environment
Check code sandbox examples
The text was updated successfully, but these errors were encountered: