React component communication is easiest when each value has one owner. Pass data from a parent to a child with props. Let a child request a change through a callback.

If siblings need the same value, lift it to their closest common parent. Use context for distant consumers and add a reducer when updates become hard to track. Start with the smallest pattern that fits the data flow.

React component communication starts with state ownership

Ask two questions before choosing an API: who owns the value, and who needs to read or change it? A component can keep private state for a detail that no other component uses.

A shared value needs a shared owner. React’s state-sharing guide moves that value to the closest common parent, then passes it down to both children.

Consider a scheduling form with a time-slot selector, a summary, and a deeply nested review panel. The selector changes the slot. The summary and review panel display it.

If each child stores its own slot, they can disagree after an update. Keep the slot in the form first. The selector receives both its current value and a way to request a new one; the summary only receives the value.

The direction matters. Props carry the current value down. A callback passed as a prop lets the child ask its owner to update.

The child does not mutate the parent’s state. On the next render, both readers get the new value. This is the data flow behind sharing state between components in React.

The React component tree is your map: find the two readers, then walk upward until you reach their first shared parent. In this React component example, that parent is the form. It keeps one value while its children take different roles.

Diagram of parent-owned state flowing to an input and summary through props, with the input sending updates through a callback

One owner supplies both readers; the input sends an update request back to that owner.

Parent-to-child props and child callbacks

React’s props guide treats props as read-only inputs to a component. Use them for a direct parent-child relationship, even if the child only displays a label. Functions can be props too, which gives a child a clear update channel.

Here is the small scheduling example. The SlotPicker emits a typed slot, and SlotSummary displays the same slot. The parent is the only component that stores it:

import { useState } from 'react';

type Slot = 'morning' | 'afternoon';

type SlotPickerProps = {
  value: Slot;
  onChange: (next: Slot) => void;
};

function SlotPicker({ value, onChange }: SlotPickerProps) {
  return (
    <label>
      Time slot
      <select
        aria-label="Time slot"
        value={value}
        onChange={(event) => onChange(event.target.value as Slot)}
      >
        <option value="morning">Morning</option>
        <option value="afternoon">Afternoon</option>
      </select>
    </label>
  );
}

function SlotSummary({ slot }: { slot: Slot }) {
  return <p>Selected slot: {slot}</p>;
}

export function ScheduleForm() {
  const [slot, setSlot] = useState<Slot>('morning');

  return (
    <>
      <SlotPicker value={slot} onChange={setSlot} />
      <SlotSummary slot={slot} />
    </>
  );
}

The as Slot assertion is safe here only because both option values are the two literals in Slot. If options come from an API or user data, validate the string before passing it to onChange. Do not make a broad type assertion your input validation.

This shape also clarifies child-to-parent communication: the picker reports an intent; the form decides what state to store. A child may validate local draft input, but the committed shared slot still has one owner. A callback is a normal prop, so the parent can replace its behavior without changing the child’s display code.

For React nested components, keep this contract explicit. A middle component that uses a value can receive it as a prop. A wrapper that only forwards many unrelated values may be a sign that composition or a local provider would make the tree clearer.

Lift state when siblings must stay in sync

The picker and summary are siblings. They never need a direct pointer to each other. Their closest common parent, ScheduleForm, owns slot. When the picker calls setSlot, React renders the form again and passes the new prop to both children. This follows the sequence in React’s lifting-state lesson.

Do not copy slot into a separate useState inside SlotSummary. That creates a second owner and a sync task. React’s state-structure guidance warns that duplicated or redundant state can drift. If the summary needs a formatted label, calculate it during render from the current prop. If a child needs a temporary edit that can be canceled, name that local value as a draft and decide when it becomes the shared value.

Lifting state has a cost: the parent now knows about the shared interaction, and its updates cause it to render again. For a small subtree, that is usually an acceptable and readable tradeoff; when repeated render work becomes measurable, evaluate React Compiler adoption after state ownership is sound. If a value is needed across many branches, first consider component composition or passing a focused child element. A long prop chain is a signal to review the tree, not proof that every value belongs in context.

The Codevolution video attached to this article walks through shared state between components. Use it alongside the example above, then test your own update path. A visual explanation is useful, but it cannot prove that a production form handles every transition correctly.

Context for distant readers

Now suppose a review panel sits several levels below the form and needs the slot. Passing slot through wrappers that never use it may hide why those wrappers have the prop. React’s context guide shows how a provider makes a value available to descendants. It also recommends trying props or composition before adding context.

Keep the provider near the part of the tree that owns the value. For example, ScheduleForm can still hold slot, while a ScheduleContext supplies it to a deep ReviewPanel. Direct children may keep using props. Context changes how descendants receive the value; it does not create a second owner.

React context applies within a provider’s rendered subtree. A query such as “react share state between pages” needs an extra ownership decision: do the pages share a mounted ancestor, or does navigation remount that owner? Choose an appropriate shared owner or persisted store for that route design; context alone does not make state survive a removed provider.

import { createContext, useContext } from 'react';

const ScheduleContext = createContext<Slot | null>(null);

function useScheduleSlot(): Slot {
  const slot = useContext(ScheduleContext);
  if (slot === null) throw new Error('Missing ScheduleContext provider');
  return slot;
}

function ReviewPanel() {
  const slot = useScheduleSlot();
  return <p>Review slot: {slot}</p>;
}

// Inside ScheduleForm's return:
// <ScheduleContext.Provider value={slot}><ReviewPanel /></ScheduleContext.Provider>

This snippet shows the read side. The provider must wrap ReviewPanel in the rendered tree, and Slot must be declared in the same file or imported. A custom hook makes a missing provider fail clearly. If deep descendants also need to request changes, provide a typed update function or dispatch through a separate context. Do not turn every short prop path into a global provider.

A reducer for complex transitions

Adding context does not simplify complex update rules. If the form gains actions such as selecting a slot, resetting a draft, and confirming a booking, transitions may be easier to audit in a reducer. React’s reducer-and-context guide combines useReducer with context when a deep tree needs both shared state and dispatch.

type Action =
  | { type: 'slot/selected'; slot: Slot }
  | { type: 'form/reset' };

function slotReducer(slot: Slot, action: Action): Slot {
  switch (action.type) {
    case 'slot/selected':
      return action.slot;
    case 'form/reset':
      return 'morning';
  }
}

The action union limits callers to known changes. A reducer groups transitions in one place; it does not automatically make a small form better. Keep useState while there is one simple value and one clear update. Introduce reducer actions when several related transitions or invariants make callbacks difficult to follow. Add context separately if distant components must read or dispatch those actions.

Four component-tree diagrams compare props, callbacks, lifted state, and context with reducer actions

Choose how a value moves through the tree separately from how its updates are organized.

Decision table and common mistakes

Relationship or need Start with State owner
Parent gives data to a direct child Props Parent or a higher owner
Child requests a change Callback prop Parent or a higher owner
Siblings need one current value Lift state, then props and callbacks Closest common parent
Distant descendants need a value Context after checking composition Provider’s stateful ancestor
Many related update rules Reducer, with context if needed Reducer host

Use the table as a starting point, then inspect the actual component tree. Props remain useful inside a context-based feature. A reducer can live in one component without context. The patterns are composable because ownership, delivery, and transition logic are separate choices.

Watch for three common mistakes. First, mirroring a prop into local state makes later parent changes easy to miss. Second, giving siblings separate copies of the same shared value creates a sync problem. Third, using a custom event bus for ordinary component updates hides who can change the value and when. An event bus may fit integration boundaries or legacy code, but document its contracts and cleanup rules; it is rarely the first choice for a local React tree.

Test the update path

One focused interaction test can catch the sibling drift that static types cannot. Render ScheduleForm, change the picker to Afternoon, and assert that both the select and summary show the new value. Test the reset action too if you adopt the reducer. For a context reader, render it once under the provider and once without a provider so the missing-provider error stays clear.

Comparison of one parent-owned value displayed as 30 in both children and duplicated child state displaying 30 versus 15

The test should catch a mismatch between two readers of what should be one shared value.

The essential assertion is behavioral: one user action produces one current value across all readers. Avoid tests that merely repeat implementation details, such as checking whether useState or useReducer was called. If a bug appears, trace the value from its owner through props or context and then trace the callback or action back to that owner. That path is the practical model for reliable React component communication.