How do you share data from a child to a parent component?
Quick answer
The parent passes a callback prop; the child calls it with the data. Data flows down, events flow up.
In detail
React enforces one-way data flow, so children can't mutate props. Instead the parent owns the state and passes a setter/handler down; the child invokes it to report changes. This keeps the data's source of truth in one place and the flow predictable.
1function Parent() {
2 const [v, setV] = useState('');
3 return <Child onChange={setV} />;
4}
5function Child({ onChange }) {
6 return <input onChange={e => onChange(e.target.value)} />;
7}Why interviewers ask this: Confirms you understand React's unidirectional data flow.
This is 1 of 118+ questions in the React Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the React Interview Kit → ₹399