ReactContext API

50 items

1

The Prop Drilling Problem Context Solves

Slides / Video
2

Re-rendering Behavior of Context Consumers

Slides / Video
3

React.memo Won't Stop Context Re-renders

Code Quiz
4

Nesting and Overriding Providers

Slides / Video
5

Custom Consumer Hook for Context

Slides / Video
6

Creating a Custom Provider Component

Slides / Video
7

Context with useReducer

Slides / Video
8

Memoizing Context Provider Values

Slides / Video
9

Splitting Contexts to Minimize Re-renders

Slides / Video
10

Providing Context Values with Provider

Slides / Video
11

Creating Context with createContext

Slides / Video
12

Creating a Context

Code Quiz
13

Default Value Without a Provider

Code Quiz
14

Providing a Context Value

Code Quiz
15

Reading Context Outside the Provider

Code Quiz
16

Context.Consumer Render Prop

Code Quiz
17

Nested Providers and Shadowing

Code Quiz
18

Updating Context via State

Code Quiz
19

Passing Updaters Through Context

Code Quiz
20

Inline Context Value Re-renders

Code Quiz
21

Reducer Missing Default Case

Code Quiz
22

Inverted Guard in Custom Context Hook

Code Quiz
23

Swapped State and Dispatch Contexts

Code Quiz
24

Custom Hook for Context

Quiz
25

Nested and Multiple Providers

Quiz
26

Splitting Contexts

Quiz
27

When to Use Context

Quiz
28

displayName for DevTools

Quiz
29

Context Value Identity Pitfall

Quiz
30

Default Value in createContext

Quiz
31

Context.Consumer Render Prop

Quiz
32

Overriding Context Values

Quiz
33

Context Re-render Behavior

Quiz
34

Context with useReducer

Quiz
35

Memoizing Context Value

Quiz
36

Creating a Context

Quiz
37

Providing Context Values

Quiz
38

Context Limitations

Flashcard
39

Context.Consumer Render Prop

Flashcard
40

Custom useContext Hook

Flashcard
41

The value Prop

Flashcard
42

Creating a Context

Flashcard
43

Providing a Context

Flashcard
44

Memoizing Context Value

Flashcard
45

Context displayName

Flashcard
46

Context with useReducer

Flashcard
47

Nesting and Overriding Providers

Flashcard
48

Default Value in createContext

Flashcard
49

Re-render on Value Change

Flashcard
50

Splitting Contexts

Flashcard
Code QuizIntermediate

Context.Consumer Render Prop

This Consumer usage crashes because of how its children are written.

Codejavascript
const ThemeContext = createContext('light');

function Button() {
  return (
    <ThemeContext.Consumer>
      <span>{theme}</span>
    </ThemeContext.Consumer>
  );
}

What is the bug in this code?