useContext lets a deeply nested component read shared data directly from a Context provider, avoiding unnecessary prop forwarding through intermediate components. section 4.2
Replacing prop drilling
Create DataContext, wrap the tree with DataContext.Provider, and read the value in ChildC with useContext(DataContext). ChildA and ChildB no longer accept or forward data props.
Evaluate the trade-offs before using useContext for shared state:
- Use it to simplify component interfaces and reduce boilerplate in deeply nested trees. section 4.2
- Account for performance costs because context changes can re-render all consuming components, even when they do not use the changed data. section 4.2


