Code Fellows Notes
With the React Context API the state can be localized to a single centralized component. That same centralized component can be responsible for rendering them, and management of that state (adding, removing) making it globally accessible. Our context provider is responsible for both displaying the local state (we call them alerts), and for exposing an API for globally managing them.
A React component that subscribes to context changes. Using this component lets you subscribe to a context within a function component. Requires a function as a child. The function receives the current context value and returns a React node.
Implement with a small wrapper around the useContext internal React hook, which consumes our new context. Read that value within any component by using the context consumer.
Wrapper components are components that surround unknown components and provide a default structure to display the child components. A wrapper component may be used to create user interface (UI) components that are used frequently throughout a design, such as modals, template pages, and information tiles.
The Provider component is going to be used to wrap the components that are going to have access to our context. The Provider component receives a prop called value , which can be accessed from all the components that are wrapped inside Provider , and it will be responsible to grant access to the context data.
Ref forwarding is not limited to “leaf” components that render DOM nodes. If you write higher order components, we recommend using ref forwarding to automatically pass the ref down to the wrapped class component instances.
StrictMode is a tool for highlighting potential problems in an application. Like Fragment, StrictMode does not render any visible UI. It activates additional checks and warnings for its descendants.
Calling the factory function will return us an object that has a “Provider” and a “Consumer” in it.