Skip to main content
Version: Current (v7.0.0-beta.3)

FormRef.reset passed as an event handler resets the form to the event

Detect​

  • Your code passes formRef.current?.reset, or another FormRef's reset, directly as an onClick or other event handler.
  • After a click, the form shows an event object's fields or empty values instead of its data.
  • In development, the console shows a warning ending in [reset-seeded-with-event] for a reset() that was passed an event. setWarningOptions() can make it throw.

Change​

FormRef.reset(seed?) now reads its argument, as reset(values) does in react-hook-form and TanStack Form: given data, it makes that data the form's seed and baseline (see reset() goes back to the seed). So reset passed straight as an event handler receives the event as its seed, and a click resets the form to the click event.

Wrap it, so it is called with no argument:

-<button type='button' onClick={formRef.current?.reset}>
+<button type='button' onClick={() => formRef.current?.reset()}>
Reset
</button>

Verify​

  • Clicking the button returns the form to its seed data.
  • The reset-seeded-with-event warning no longer appears.

Warns at run time as reset-seeded-with-event.

Also read: