React
/Beginner
Parent to Child Communication
Definition
The standard unidirectional data flow in React where a parent component passes data down to a child component using Props.
Explain Like I'm New
Imagine a manager giving a task to an employee. The manager (Parent) writes the instructions on a clipboard (Props) and hands it down to the employee (Child). The employee just reads the clipboard and does the work.
Real World Example
A `<UserProfile>` component fetches user data from an API, and passes `name` and `avatarUrl` down as props to a `<ProfileAvatar>` child component.
Common Use Cases
- •Passing pure data to presentational components
- •Configuring child component behavior (e.g., `isDisabled={true}`)
Interactive Example
Loading Code Playground...
Interview Questions
basic
- How does a parent pass data to a child?
- Can a child change the props passed to it by the parent?
intermediate
- What happens to the child when the parent's state changes?
- How do you pass a large number of props without writing them all out manually?
advanced
- How can you prevent a child from re-rendering if the parent re-renders but the props haven't changed?
trick
- If you pass a prop down as `initialValue={10}` and the parent later changes it to `20`, does the child's internal `useState(initialValue)` update to 20?