Skip to content

[Suggestion]: improve <Form> documentation to explain how to keep form state after submission #8397

@MaxwellCohen

Description

@MaxwellCohen

Summary

facebook/react#29034 raises concerns about actions resetting forms. There are many use cases where developers would want to prevent the form from resetting. Since React's behavior is not expected to change, the docs should explain to users how to control form resets and preserve the form's previous state.

Page

https://un5pnj1xgk7x0.julianrbryant.com/reference/react-dom/components/form

Details

I do not know the best way to provide this information. Some suggestions include:

  1. Add a deep dive on when to use onSubmit vs action props.
  2. Include an example of opting out of automatic resets using an example based on @eps1lon comment here: [React 19] allow opting out of automatic form reset when Form Actions are used facebook/react#29034 (comment). The issue has several other workarounds that may or may not be endorsed by the Rect team.
  3. Update the Handling multiple submission types example so that the "Save draft" button will keep the text of the form.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions