Reading-Notes

Class 32 Summary:

Context API - Behaviors :

When you have multiple contexts, what component type should you use (class/function) and why?

What are some good use cases for using the Context API for global state?

  1. Twilio : Twilio really defines what it means to be API-driven.
  2. Stripe : Stripe is one of the most successful and best known API-driven businesses.
  3. Ebay : Unlike the previous companies, eBay didn’t start out with the intent of being API-driven.
  4. Salesforce : XML APIs have been a part of Salesforce since day one, back in 2000 when it launched.
  5. Rovi :Rovi is definitely the oldest company on the list, founded as Macrovision in 1983.

Document the following Vocabulary Terms :

Term  
context a method to pass props from parent to child component(s), by storing the props in a store(similar in Redux) and using these props from the store by child component(s) without actually passing them manually at each level of the component tree
useContext() create common data that can be accessed throughout the component hierarchy without passing the props down manually to each level
static context which wraps our component with PureComponent shallow comparison logic while also allowing us to pass references from our context

Context :

When to Use Context :

image1

Before You Use Context :

React.createContext :

Context.Provider:

Class.contextType :

Context.Consumer :

Caveats:

An Exercise in Hooks and Context:

Sources :

source1 sourcse2