liveBook · Manning

Unidirectional data flow

As explained in Acing the Frontend Interview

One-way data flow propagates application data through an interface hierarchy in a single direction.

A unidirectional data pipeline moves data predictably from parent components to child components through props. The parent remains the source of truth, while children receive read-only data and request changes through updater functions. React then updates state, reconciles, and re-renders affected components, reducing unintended side effects and simplifying debugging. section 1.4 section 4.2

Use the pipeline to reason about React state and component boundaries:

  • Keep state in the parent or another appropriate source of truth, then pass values downward as props. section 4.2
  • Let children trigger changes by calling callbacks rather than modifying parent state directly. section 4.2
  • Lift state to a common ancestor when multiple components need coordinated access. section 1.4 section 4.2
  • Recognize prop drilling when intermediate components pass data they do not use; consider Context API or a state container when that becomes cumbersome. section 4.2

Prop drilling and Context API

A parent can pass data through ChildA and ChildB until ChildC displays it, even though the intermediate components do not use it. Context API moves the shared value into a provider, allowing ChildC to read it directly with useContext while preserving a one-way update model. section 4.2 section 4.2

Table 4.5 Data flow in React
Topic
Fundamentals
Applied skills
Advanced
One-way data binding
Explain unidirectional flow.
Manage props, lifting state up.
Architect Context API or state container patterns for global state.
State management options
Use useState, useReducer.
Apply Context API effectively.
Architect advanced state management solutions with Redux ( https://redux.js.org), MobX ( https://mobx.js.org), Zustand ( https://zustand.docs.pmnd.rs), Jotai ( https://jotai.org), or Recoil ( https://recoiljs.org).
Context API
Share state globally without props.
Combine with useReducer for complex global state.
Optimize context re-renders, split contexts for performance.

Compare foundational one-way flow with lifting state, Context API, and advanced state-management patterns. section 4.2

How Acing the Frontend Interview covers it

How deep it goes
Explains props, updater functions, reconciliation, prop drilling, and Context API, while deferring detailed state-container architecture.
Examples
Uses nested prop drilling through ChildA, ChildB, and ChildC, then contrasts it with a Context API provider.
What it assumes
Assumes React component and state fundamentals while reinforcing predictable data flow and maintainability.
What you can do after
Apply it via React props, callbacks, lifted state, Context API, and suitable state-management patterns.
How it connects
Connects React components, props, state management, lifting state, Context API, reconciliation, and global state.

Also explained in

Compare how 3 books explain unidirectional data flow →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.