reactjs / reactjs/react.dev

Document Controlled vs Uncontrolled Component Design pattern

Offen
#918 14 Kommentare 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

pursuant to this discussion https://twitter.com/dan_abramov/status/1001943857096003584

all react components can be:

  • controlled (no internal state)
  • uncontrolled (internal state)
  • mixed (uncontrolled by default, unless some props are passed to make it controlled)

the current docs on controlled vs uncontrolled: https://reactjs.org/docs/uncontrolled-components.html focus entirely on forms, but this design pattern applies to -all- components. we should document this.

questions

  1. What else should we say in the docs?
  2. do we want to tell people that they can do "mixed control" or do we leave that for people to discover for themselves?
  3. is this the same page as https://reactjs.org/docs/uncontrolled-components.html or is it a separate page?

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 bestehenden Dokumentation zu uncontrolled-components.html und der verlinkten Diskussion. Kläre, ob controlled, uncontrolled und mixed component patterns auf diese Seite oder auf eine separate Seite gehören, und bestimme, welche Hinweise die Dokumentation geben sollte. Erledigt ist die Aufgabe, wenn die ausgewählte Dokumentation das Pattern über Formulare hinaus klar abdeckt und die offenen Fragen zum Umfang beantwortet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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