We use cookies to enhance your browsing experience.
Catch errors in child component tree.
class ErrorBoundary extends React.Component { state = { hasError: false }; static getDerivedStateFromError(error) { return { hasError: true }; } render() { if (this.state.hasError) return <h1>Something went wrong.</h1>; return this.props.children; } }
We use cookies to enhance your experience and serve personalized ads.