Errors in React
As of React 16, errors that were not caught by any error boundary will result in unmounting of the whole React component tree.
Components that catch Javascript Errors from child components, log those and display a fallback UI instead of crashing.
defines one or both of static getDerivedStateFromError()
or componentDidCatch()
Does not catch:
Event handlers - react wont crash here so you should handle
Asynchronous code (e.g.
setTimeout
orrequestAnimationFrame
callbacks)Server side rendering
Errors thrown in the error boundary itself (rather than its children)
Usage
ErrorBoundary
Last updated