Context and Shared State
Stop threading props through layers that do not need them. Create a context, provide a value, consume it with useContext, and avoid the performance traps.
- Level
- Intermediate
- Chapters
- 4
- Exercises
- 1
- Reading time
- 15 min
What you will cover
- 1. The Prop Drilling ProblemWhat context is for, and the cheaper fixes worth trying first.
- 2. Creating and Using ContextThe three pieces: create, provide, consume.
- 3. Context and Re-rendersThe one performance trap everyone hits, and how to avoid it.
- 4. Context with a ReducerThe standard pattern for app-wide state without a library.
Up next after this one: useReducer and Complex State