2018-11-21 16:04:37 +01:00
|
|
|
import React from 'react'
|
2018-05-31 11:47:29 +02:00
|
|
|
|
2018-11-21 16:04:37 +01:00
|
|
|
class ErrorBoundary extends React.Component {
|
|
|
|
componentDidCatch (error, info) {
|
2018-05-31 11:47:29 +02:00
|
|
|
const {onError} = this.props
|
2018-07-24 11:24:40 +02:00
|
|
|
// onError is required
|
|
|
|
onError(error, info)
|
2018-05-31 11:47:29 +02:00
|
|
|
}
|
|
|
|
render () {
|
2018-07-24 11:24:40 +02:00
|
|
|
const {children} = this.props
|
2018-05-31 11:47:29 +02:00
|
|
|
return React.Children.only(children)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ErrorBoundary
|