reactjs / reactjs/react.dev

Resetting state docs improvement

Abierto
#6,578 5 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
JavaScript
Estrellas
11.8k
Forks
7.9k
Merge medio
1 d 11 h
PR fusionados (30 d)
11

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza por la sección enlazada «Option 1: Rendering a component in different positions» y revisa su diagrama y explicación de los hijos condicionales. Compara la redacción con la forma en que React trata los false children y las posiciones en el árbol. Se considera terminado cuando el diagrama y el texto explican correctamente los tres casos sin dar a entender que la colocación visual a la izquierda o a la derecha define la identidad de un hijo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, react
Área
documentation
Tipo de issue
Documentación
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.