Why gets event handler passed from parent to child component?


#1
HI,

does anyone know the exact reason, why the event handler function has been defined inside the parent component and not inside the child (button) component?
Is the reason to keep all event handler functions in one place (the parent)?

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/react-101/lessons/this-props/exercises/event-handler-pass-prop


#2

yes, code structure/organization, one class to handle the logic and one class to handle the presentation.

its nicely explained here:

and i believe as well somewhere in part 1 or part 2 of the React course


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.