Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 6.5 — One-Way Data Flow: Props Down, Events Up
React · Example 1 of 3

Siblings talk through their parent

Type an or tick the checkbox. SearchBar and ProductTable never reference each other; the parent owns the two facts and both children read them.

In React, data travels one way: parents pass values down as props, and children report events up by calling callback props; siblings talk through their shared parent, and passing props through many layers that don't use them is called prop drilling.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a Rating component that shows 5 star buttons and calls onRate(n) when star n is clicked, and a parent that stores the rating and shows You rated N/5.

02

A ColorPicker and a Preview box are siblings. Make choosing a colour in the picker change the preview's background.

Explain it without notes

01

What is one-way data flow, and why does React use it?

02

How does a child component tell its parent that something happened? Show a small example.

03

Two sibling components need the same data. How do they communicate?

04

What is prop drilling, when is it fine, and what are the fixes?

Siblings talk through their parent

Preview

Press Run to see the page.

Console

Nothing logged yet.