Chapter 16 · 6 examples

Universal error handling in React

Why we should catch errors in React · Remembering how to catch errors in JavaScript · Simple try/catch in React: how to and caveats · React ErrorBoundary component · ErrorBoundary component: limitations · Catching async errors with ErrorBoundary · Can I just use the react-error-boundary library instead?

  1. Example 1try/catch inside useEffect
  2. Example 2Errors in children components
  3. Example 3State updates during render
  4. Example 4Reusable ErrorBoundary component
  5. Example 5Re-throwing async errors
  6. Example 6useThrowAsyncError hook