← BYTES
React.js·Intermediate·Ref: 4.2.14

What is the idiomatic way for a child component to notify its parent that something happened (e.g. a button was clicked inside the child)?

Have a question about this video? Mention reference 4.2.14 when you contact us.

a.The child directly modifies a variable owned by the parent
b.Children cannot communicate anything back up to parents in React
c.The parent passes a callback function down as a prop, and the child calls that function when the event occurs
d.The child dispatches a native browser `CustomEvent` that the parent must manually listen for on `window`
Since data flows down via props, the standard way for a child to communicate upward is for the parent to hand the child a callback prop (e.g. `onSomething`), which the child invokes at the appropriate moment, letting the parent react to it.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES4214#Reactjs