Skip to the content.
Home Page
Class 33 Notes
Review, Research, and Discussion
- Context API gives you a way to pass global data to children components without having to manually pass down props through every component.
- A component outside of a provider can consume the context using the useContext() hook.
- You could use it to create a dark mode or light mode. It can also be useful for authentication/authorization.
- Context hell is when you nest providers and make them children of each other.
Terms
- Global State: Data that all components share.
- Global Context: A way to share global state to all components without passing down props.
- Provider: Allows consuming components to subscribe to context changes.
- Consumer: A React component that subscribes to context changes.