React · Junior · Question 9 of 75
How can a child component pass data to its parent?
- ✓Correct answer: The parent passes a callback via props, and the child calls it with the data
- 2The child mutates the props object, and the parent sees the new value
- 3Via
this.parent.setState()inside the child component
Explanation
In React, data flows down and events flow up through functions: <Search onChange={setQuery} />, and the child calls props.onChange(value). Mutating props won't re-render the parent, and function components have no access to the parent instance.