react.dev
react.dev copied to clipboard
A section quite vague
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.
+1
Need some further clarification on this please.