[Suggestion]: improve <Form> documentation to explain how to keep form state after submission
Open
Nobody has claimed this yet.
type: documentation
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
Summary
https://github.com/facebook/react/issues/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://react.dev/reference/react-dom/components/form
Details
I do not know the best way to provide this information. Some suggestions include:
- Add a deep dive on when to use onSubmit vs action props.
- Include an example of opting out of automatic resets using an example based on @eps1lon comment here: https://github.com/facebook/react/issues/29034#issuecomment-2143595195. The issue has several other workarounds that may or may not be endorsed by the Rect team.
- Update the Handling multiple submission types example so that the "Save draft" button will keep the text of the form.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the React
reference page, especially the “Handling multiple submission types” example, and review issue #29034 and the linked comment for the reset behavior and proposed workarounds. Done means the page clearly explains how to preserve form state after submission and includes an agreed, accurate example without endorsing unsupported behavior.Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100