Skip to content

Checkbox behavior changed in react 19 when not providing initial values #4017

@mmussmann

Description

@mmussmann

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:

  1. Click checkbox
  2. Click submit
  3. Inspect resulting alert

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions