1
ReactIntermediate#lifecycle#hooks
A class component implementing componentDidCatch/getDerivedStateFromError that catches render-time errors in its subtree and shows a fallback UI instead of a blank page. It does not catch event handler or async errors.
class Boundary extends React.Component {
state = { failed: false };
static getDerivedStateFromError() { return { failed: true }; }
render() { return this.state.failed ? <p>Something broke</p> : this.props.children; }
}