What problems does Context solve compared to prop drilling?
Prop drilling happens when you pass props down multiple layers of components just to get data to a deeply nested child. This leads to:
- Repetitive and bloated code.
- Components getting props they don't really use — just passing them along.
- Harder maintenance when app grows.
Context API solves this by:
- Making the data globally available to any component.
- Reducing dependency chains — a deeply nested component can directly access the data without intermediate components knowing about it.
- Cleaner, more maintainable code.