- Tutorials
- React Tutorial
- Context
Context
2 lessonsAbout 12 minutesAdvanced
This part of the React Tutorial runs from useContext Explained through to Context Patterns. There are 2 lessons here, and working through them takes about 12 minutes at a steady pace.
It follows on from Data and Errors, so finish that first if you have not already — the examples below assume you are comfortable with it.
Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.
- 1useContext ExplainedContext passes data through the tree without prop drilling. Learn createContext, Provider and useContext, and when context is the wrong answer.
- 2Context PatternsWrap context in a custom provider and hook, split fast and slow values, and avoid the re-render caused by a new object every render.
