Prop Drilling
Question
What is prop drilling and how to avoid it?
Hint
Context API, composition, or state libraries solve prop drilling.
Explanation
Prop drilling (threading) occurs when data must pass through multiple component layers that do not use it, just to reach a deeply nested child. This makes code harder to maintain and refactor. Solutions: 1) Context API — provide value at the top, consume where needed. 2) Component composition — pass children or render functions. 3) State management libraries (Zustand, Redux) — access state directly. 4) Colocate state — move state closer to where it is used. Choose based on how widely the data is needed.
Related Resources
Related Lessons
- useContext
Learn useContext.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.