[Suggestion]: improve <Form> documentation to explain how to keep form state after submission
未关闭
还没有人认领这个 Issue。
type: documentation
- 主要语言
- JavaScript
- 星标
- 11.8k
- 派生
- 7.9k
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 11
描述
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 React 的
参考页面开始,尤其是“Handling multiple submission types”示例,并查看 issue #29034 及其中链接的评论,了解 reset 行为和提议的变通方案。完成标准是:页面清楚说明如何在提交后保留表单状态,并包含一个经过认可且准确的示例,同时不认可不受支持的行为。由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100