React Context provides shared values to descendant components without forcing unrelated intermediate components to accept and forward props. It addresses prop drilling while preserving a component’s one-way data-flow model. section 4.2 section 1.4
Interview-ready trade-offs:
- Create a context, wrap descendants with its Provider, and read the value where needed with useContext. section 4.2
- Use Context for shared state, but consider performance: changes can re-render all consuming components, even when only part of the state changes. section 4.2
- For complex global state, combine Context with useReducer; larger applications may instead evaluate Redux, MobX, Zustand, Jotai, or Recoil. section 4.2
Replacing prop drilling
Prop drilling passes data through ChildA and ChildB even though only ChildC uses it. Context removes those intermediary props: createContext<DataProps>({ data: '' }); wrap the tree with <DataContext.Provider value={{ data }}>; then read it in ChildC with const data = useContext(DataContext). 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 one-way data binding, Context API, useReducer, and state-container choices by fundamentals, application, and optimization concerns. section 4.2



