reactjs / reactjs/react.dev

Resetting state docs improvement

Offen
#6,578 5 Kommentare 1 Reaktion 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

Over here: https://react.dev/learn/preserving-and-resetting-state#option-1-rendering-a-component-in-different-positions
about resetting a state, just because a line is drawn to the right, now the Counter becomes a "right" child?

And then, just because the line is drawn to the left, now the Counter becomes a "left" child?

The diagram is:

Screenshot 2024-01-23 at 9 23 57 PM

In reality, it is just "children" nodes. So if you have one child with a line drawn to the left, it doesn't make it a "left" child.

Likewise, if you have one child with a line drawn to the right, it doesn't make it a "right" child.

To some degree, it dumbs down the programmers.

The truth is:

For those three situations in the diagram:

  1. First child is Counter, and second child is false. (isPlayerA && whatever becomes false if isPlayer is false). There should be a solid line going to a false as a second child.
  2. First child is false, and second child is Counter. There should be a solid line going down to the first child which is false.
  3. The third case is just like (1).

And then, the rule of React is, the false will not be rendered. But the tree in fact has a false, for the "tree structure" to be "different".

If I am not mistaken, this "tree" is composed, and compared to the previous "tree", for React to decide whether to change something in the actual DOM. This "current" tree and "previous tree", is the idea of Virtual DOM.

So the concepts should be set straight here.

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 beim verlinkten Abschnitt „Option 1: Rendering a component in different positions“ und prüfe dessen Diagramm und Erklärung bedingter Kinder. Vergleiche die Formulierung damit, wie React false children und Positionen im Baum behandelt. Erledigt ist dies, wenn Diagramm und Text die drei Fälle korrekt erklären, ohne anzudeuten, dass die visuelle Platzierung links oder rechts die Identität eines Kindes bestimmt.

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
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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