Lesson 2 of 80
Props are the arguments a component is called with — read-only, and flowing in exactly one direction: parent to child.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 4
A child component needs to change a value its parent owns. What's the correct way to do that?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
If a component is a function (see the last lesson), props are its arguments. A parent component calls a child component with some values; the child reads them but never changes them.
Data only flows one way: parent → child. There's no built-in mechanism for a child to reach up and change something on its parent directly.
function App() {
const [count, setCount] = useState(0);
return <Counter value={count} onIncrement={() => setCount((c) => c + 1)} />;
}
function Counter({ value, onIncrement }) {
return (
<button onClick={onIncrement}>
Count: {value}
</button>
);
}
Counter never touches count directly — it can't, it doesn't own it. Instead, App passes Counter a callback: a function Counter can call, which runs back in App and updates the state App actually owns. Data flows down as value; the request to change it flows back up as a function call. That's the whole trick behind every "child talks to parent" interaction in React.
<Greeting name="Ada" /> — props are just the arguments passed into a component function.
<UserCard style={{ color: "red" }} /> creates a brand-new object each time UserCard's parent re-renders — even though it looks identical. That matters a lot once memoization enters the picture.children is just a prop. <Card><p>hi</p></Card> passes <p>hi</p> as props.children — there's no separate mechanism for nested content."How does a child component change something in its parent?" is really asking whether you understand one-way data flow at all — the honest answer ("it can't directly; it calls a function the parent handed it") is the foundation prop drilling, context, and lifting state up all build on.