React Hooks Context API

When to use Context

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.

Simple Explanation

  1. Create context - React.createContext()
  2. Provide context - YourContext.Provider
  3. Consume context - useContext(YourContext)

How to update React Context from inside a child component?

:+1: 使用步驟說明

套上實例 play video

Tutorial