reactjs / reactjs/react.dev

Resetting state docs improvement

Open
#6,578 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the linked “Option 1: Rendering a component in different positions” section and review its diagram and explanation of conditional children. Compare the wording with how React treats false children and positions in the tree. Done means the diagram and text accurately explain the three cases without implying that visual left or right placement defines a child’s identity.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.