Drinking coffee and saving the world. Software Engineer and professional geek
the Context API
by Gian Marco Toso - @gianmarcotoso
self employed / polarityb.it
starting at 11:30
The Context API
Context provides a way to pass data through the component tree without having to pass props down manually at every level.
- Official React Docs
How Does it work?
returns both a Provider and a Consumer
Wrapping a component tree with a Provider makes it so that every time its value changes, all the contained Consumers automatically re-render.
When Should I use it?
- Sharing simple data between components (The current theme, etc...)
- Application-wide functionality (Notification Managers, etc...)
- Can I use multiple contexts?
- When should I *not* use context?
React: Context API
By Gian Marco Toso