reactjs / reactjs/react.dev

A section quite vague

Ouverte
#6,293 1 commentaire 3 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

In https://react.dev/learn/responding-to-events#passing-handlers-as-alternative-to-propagation

You could add more code to this handler before calling the parent onClick event handler, too. This pattern provides an alternative to propagation. It lets the child component handle the event, while also letting the parent component specify some additional behavior. Unlike propagation, it’s not automatic. But the benefit of this pattern is that you can clearly follow the whole chain of code that executes as a result of some event.

If you rely on propagation and it’s difficult to trace which handlers execute and why, try this approach instead.

It is somewhat abstract what it is talking about. "You could add more code" -- add more code for what purpose?

"This pattern provides an alternative to propagation" alternative to propagation? Why do I need to rely on propagation in the first place? (and such that I now need an "alternative"?)

"while also letting the parent component specify some additional behavior." What additional behavior?

"But the benefit of this pattern is that you can clearly follow the whole chain of code that executes as a result of some event." Follow the chain? What do you mean?

"If you rely on propagation and it’s difficult to trace which handlers execute and why, try this approach instead." What approach? Why do we "rely on propagation" in the first place?

Can you talk about something specific. Perhaps using an example with specific things. Right now it is quite abstract.

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

Commencez par lire la section « Passing Handlers as Alternative to Propagation » à l’URL liée de la documentation React et comparez-la avec le contenu environnant sur la gestion des événements. Révisez l’explication avec un exemple précis qui clarifie l’objectif, le comportement du parent et la chaîne d’exécution, puis vérifiez que les affirmations abstraites citées sont compréhensibles pour une personne débutante.

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é
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

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