0Pricing
React Academy · Lesson

Sibling Communication Patterns

Coordinate two sibling components through shared parent state and callback props.

Sibling Communication Patterns is a free React Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the React Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Welcome

In this lesson you will implement sibling communication in React by coordinating two components through shared parent state and callback props.

Siblings Cannot Talk Directly

In React, data flows down through props. Two siblings have no direct connection. All sibling communication goes through their common parent.

The Pattern: Shared State in Parent

The parent holds the shared value in state and passes it to both siblings: one receives it as data (reader), the other receives a callback to change it (writer).
function Parent() {
  const [selected, setSelected] = useState(null);
  return (
    <>
      <Picker onSelect={setSelected} />
      <Detail item={selected} />
    </>
  );
}

Reader and Writer Siblings

The writer sibling (Picker) calls the parent callback when the user makes a selection. The reader sibling (Detail) receives the resulting value as a prop. Neither sibling knows about the other.
function Picker({ onSelect }) {
  return <button onClick={() => onSelect('item-1')}>Pick item 1</button>;
}

function Detail({ item }) {
  return <p>Selected: {item}</p>;
}

Two-Way Communication

Both siblings can be readers and writers simultaneously. Each receives the current value AND an onChange callback. Changes from either sibling update the shared parent state, which flows back down to both.

Synchronised Form Fields Example

A slider and a number input both control the same value. Both receive the value and onChange from the parent. Changing either component updates the other automatically.
function VolumeControl() {
  const [vol, setVol] = useState(50);
  return (
    <>
      <input type="range" value={vol} onChange={e => setVol(+e.target.value)} />
      <input type="number" value={vol} onChange={e => setVol(+e.target.value)} />
    </>
  );
}

Avoiding Event Bus Anti-Pattern

Avoid using a global event emitter (EventEmitter/PubSub) for sibling communication in React. This bypasses React's data flow, making state invisible and debugging hard.

When Siblings Are Far Apart

If the siblings are deeply nested under different branches of the tree, lifting state all the way up to their common ancestor causes excessive drilling. That is when Context or a state library is appropriate.

Keeping Siblings Decoupled

Neither sibling should import or reference the other. The parent is the coordinator. This decoupling makes it easy to replace one sibling without affecting the other.

Testing Sibling Communication

Test the parent component: simulate an action in the writer sibling (via the parent's interface) and assert that the reader sibling displays the correct value. The parent is the testable unit of coordination.

Quick Check

How do two sibling React components communicate with each other?

Recap

Coordinate siblings through their common parent: the parent holds shared state, passes data to readers, and passes callbacks to writers. Neither sibling needs to know about the other.

Up Next

Next lesson: **Choosing the Right State Location** — you will apply a decision framework for local, lifted, or global state.

Frequently asked questions

Is the “Sibling Communication Patterns” lesson free?

Yes — the full text of “Sibling Communication Patterns” is free to read here on the web, and the React Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the React Academy course, upgrade to CoddyKit PRO.

What will I learn in “Sibling Communication Patterns”?

Coordinate two sibling components through shared parent state and callback props. You practise React Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start React Academy?

No prior experience is required. React Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Sibling Communication Patterns” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this React Academy lesson?

Yes. Every React Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Lifting State Up: Principles & Examples
  2. Prop Drilling: When It Hurts & When It's Fine
  3. Sibling Communication Patterns
  4. Choosing the Right State Location
← Back to React Academy