Explore Library
ReactPatterns & Best Practices

73 items

1

Container Forgets to Pass Data

Code Quiz
2

Render Prop Rendered as Element

Code Quiz
3

PropTypes and TypeScript for Type Safety

Slides / Video
4

Immutability in State Updates

Slides / Video
5

Separating Business Logic from UI

Slides / Video
6

Small Single-Responsibility Components

Slides / Video
7

Naming Conventions for Components and Files

Slides / Video
8

Folder and File Organization Strategies

Slides / Video
9

Three React Anti-Patterns to Avoid

Slides / Video
10

Deriving State Instead of Duplicating

Slides / Video
11

Colocating State Near Usage

Slides / Video
12

React.memo for Component Memoization

Slides / Video
13

Compound Component Pattern

Slides / Video
14

Proper Use of Keys in Lists

Slides / Video
15

Conditional Rendering Best Practices

Slides / Video
16

Lifting State Up

Slides / Video
17

Render Props Pattern

Quiz
18

Higher-Order Components Basics

Quiz
19

Container vs Presentational Components

Quiz
20

Compound Components Pattern

Quiz
21

Deriving State Instead of Duplicating

Quiz
22

Colocating State

Quiz
23

Immutable State Updates

Quiz
24

Composition over Inheritance

Quiz
25

Prop Drilling and Context

Quiz
26

Single Responsibility Components

Quiz
27

Fragments Avoid Wrapper Divs

Quiz
28

Lifting State Up

Quiz
29

Controlled vs Uncontrolled Inputs

Quiz
30

Error Boundaries

Quiz
31

Component Folder Structure

Quiz
32

Inline Functions in Render

Quiz
33

Accessibility in Component Design

Quiz
34

Higher-Order Components (HOCs)

Slides / Video
35

Composition with the children Prop

Slides / Video
36

Composition over Inheritance

Slides / Video
37

Container/Presentational Pattern

Slides / Video
38

Lifting State That Stayed Local

Code Quiz
39

Prop Drilling Passes Wrong Name

Code Quiz
40

HOC Swallows the Props

Code Quiz
41

Controlled Input Without onChange

Code Quiz
42

Compound Component Loses Context

Code Quiz
43

Composition Ignores Children

Code Quiz
44

Modal Rendered Without a Portal

Code Quiz
45

Fragment Loses the Key

Code Quiz
46

State Lifted Too High

Code Quiz
47

Wrong PropType for Callback

Code Quiz
48

Barrel Export Missing the Component

Code Quiz
49

Component Doing Too Much

Code Quiz
50

List Key on the Wrong Element

Code Quiz
51

Error Boundary as a Function

Code Quiz
52

Derived Value Stored in State

Code Quiz
53

Inline Object Defeats Memoization

Code Quiz
54

React.memo That Never Memoizes

Code Quiz
55

Zero Leaks Into the UI

Code Quiz
56

Card Component Ignores Children

Code Quiz
57

Lazy Component Without Suspense

Code Quiz
58

Fragments to Avoid Wrapper Nodes

Flashcard
59

Provider Pattern for Shared State

Flashcard
60

Extracting Reusable UI Components

Flashcard
61

Default Props and Prop Validation

Flashcard
62

React.memo Best Practices

Flashcard
63

Compound Components Pattern

Flashcard
64

Render Props Pattern

Flashcard
65

Container/Presentational Pattern

Flashcard
66

Avoiding Inline Functions/Objects

Flashcard
67

Deriving State

Flashcard
68

Prop Drilling and Avoiding It

Flashcard
69

Colocating State

Flashcard
70

Small, Focused Components

Flashcard
71

Lifting State Up

Flashcard
72

Component File Organization

Flashcard
73

Prop Naming & API Design

Flashcard
Code QuizIntermediate

Error Boundary as a Function

An error boundary is written as a function component and never catches errors.

Codejavascript
function ErrorBoundary({ children }) {
  const [hasError, setHasError] = useState(false);

  if (hasError) return <h1>Something went wrong</h1>;

  return children;
}

Why will this error boundary fail to catch rendering errors?