Read: Class 33 Context API - Goorob-401-advanced-javascript/amman-javascript-401d1 GitHub Wiki

Context :

Context provides a means of passing state down the component tree through a Provider/Consumer relationship. At as high a level as makes sense, a “provider” can make it’s state available, along with means of altering it (methods).

Context is designed to share data that can be considered “global” for a tree of React components, such as the current authenticated user, theme, or preferred language. Creates a Context object. When React renders a component that subscribes to this Context object it will read the current context value from the closest matching Provider above it in the tree.

The defaultValue argument is only used when a component does not have a matching Provider above it in the tree. This can be helpful for testing components in isolation without wrapping them. Note: passing undefined as a Provider value does not cause consuming components to use defaultValue.