UNPKG

339 BJavaScriptView Raw
1import React from 'react'
2
3export default class ErrorBoundary extends React.Component {
4 state = { hasError: false }
5
6 componentDidCatch(error, info) {
7 // Display fallback UI
8 this.setState({ hasError: true })
9 }
10
11 render() {
12 if (this.state.hasError) {
13 return <div>:/</div>
14 }
15
16 return this.props.children
17 }
18}