When you have multiple contexts, what component type should you use (class/function) and why?
- use a function component since you can just import it using the useContext hook and wrap your code in multiple context.provider elements, whereas class components can only consume one context.
What are some good use cases for using the Context API for global state?
- current authenticated user, theme (typically light or dark), or perferred language
How can you best test context?
- The best way to test Context is to make our tests unaware of its existence and avoiding mocks. We want to test our components in the same way that developers would use them (behavioral testing) and mimic the way they would run in our applications (integration testing). source
context
- Context provides a way to pass data through the component tree without having to pass props down manually at every level. source
useContext()
- the hook for utilizing context in functional components
static context
- A property of the class component