Chapter 5 · 7 examples

Memoization with useMemo, useCallback and React.memo

The problem: comparing values · useMemo and useCallback: how they work · Antipattern: memoizing props · What is React.memo · React.memo and props from props · React.memo and children · React.memo and memoized children (almost) · useMemo and expensive calculations

  1. Example 1useMemo versus useCallback
  2. Example 2Memoized props for React.memo
  3. Example 3Spread props break memoization
  4. Example 4Custom hooks break memoization
  5. Example 5Children as a prop
  6. Example 6Memoizing render prop children
  7. Example 7Nested memoized children