on f6af024 help sign in
bridge/src/components/WithErrorBoundary.jsx
20 lines 379 B history raw
1import React from 'react';
3export default class WithErrorBoundary extends React.Component {
4 static getDerivedStateFromError(error) {
5 return { error };
6 }
7 constructor(props) {
8 super(props);
10 this.state = { error: null };
11 }
13 render() {
14 if (this.state.error) {
15 return this.props.render(this.state.error);
16 }
18 return this.props.children;
19 }