Skip to content

Commit

Permalink
Add missing component
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Jul 30, 2021
1 parent 25d8a78 commit 2c7110c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/ErrorBoundary.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';

export default class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}

static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}

componentDidCatch(error, errorInfo) {
// eslint-disable-next-line
console.error(error, errorInfo);
}

render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <strong>Error in component</strong>;
}

return this.props.children;
}
}

0 comments on commit 2c7110c

Please sign in to comment.