reactjs / reactjs/react.dev

The following two paragraphs in "Splitting High and Low Priority State" in Concurrent UI Patterns creates confusion

Ouverte
#2,715 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
JavaScript
Étoiles
11.8k
Forks
7.9k
Merge moyen
1 j 11 h
PR mergées (30 j)
11

Description

When you design React components, it is usually best to find the “minimal representation” of state. For example, instead of keeping firstName, lastName, and fullName in state, it’s usually better keep only firstName and lastName, and then calculate fullName during rendering. This lets us avoid mistakes where we update one state but forget the other state.

However, in Concurrent Mode there are cases where you might want to “duplicate” some data in different state variables.

Isn't this how we build React apps anyways -- we store query value in a one state and data in another state? I am asking this because the description at the beginning of this section does not provide relevant information for the rest of the section, which mainly talks about moving setResource to startTransition to make it "low priority". In contrary, it creates a confusion that putting input value and API data in the same state was a normal occurrence. Even in the provided example, we are not really duplicating data -- we are just using each data in a different way (one in a normal way and another one inside startTransition).

If the idea of duplication is that resource and state coexist as a duplicate data, I think that also contradicts all the previous sections on this page because we have been storing "concurrent resource" in the state for "profile change" example etc.

I suggest that we remove these bits and replace it with something like:

In the past, when designing React components, we would handle input state and data state within the same application flow using React's state management. However, existing flow cannot be applied when data is being handled using concurrent mode APIs. Consider this tiny translation app:

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Repérez la section « Splitting High and Low Priority State » dans la documentation de React et lisez le contenu environnant de Concurrent UI Patterns. Remplacez les paragraphes d’introduction confus par une formulation cohérente avec l’exemple de input state, data state et startTransition ; le travail est terminé lorsque l’explication de la section est cohérente avec l’exemple et les sections précédentes.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, react
Domaine
documentation
Type d'issue
Documentation
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
55/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.