reactjs / reactjs/react.dev

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

Offen
#8,397 1 Kommentar 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

type: documentation
Vorherrschende Sprache
JavaScript
Sterne
11.8k
Forks
7.9k
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
11

Beschreibung

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:

  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: 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.
  3. Update the Handling multiple submission types example so that the "Save draft" button will keep the text of the form.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der React-Referenzseite zu

, insbesondere mit dem Beispiel „Handling multiple submission types“, und prüfe Issue #29034 sowie den verlinkten Kommentar zum Reset-Verhalten und zu den vorgeschlagenen Workarounds. Als erledigt gilt die Aufgabe, wenn die Seite klar erklärt, wie der Formularzustand nach dem Absenden erhalten bleibt, und ein abgestimmtes, korrektes Beispiel enthält, ohne nicht unterstütztes Verhalten zu empfehlen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, react
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.