@gechiui/block-editor
Version:
31 lines (24 loc) • 435 B
JavaScript
/**
* GeChiUI dependencies
*/
import { Component } from '@gechiui/element';
class BlockCrashBoundary extends Component {
constructor() {
super( ...arguments );
this.state = {
hasError: false,
};
}
componentDidCatch() {
this.setState( {
hasError: true,
} );
}
render() {
if ( this.state.hasError ) {
return this.props.fallback;
}
return this.props.children;
}
}
export default BlockCrashBoundary;