rsnext/packages/next/client/error-boundary.js

16 lines
323 B
JavaScript
Raw Normal View History

import React from 'react'
class ErrorBoundary extends React.Component {
componentDidCatch (error, info) {
const {onError} = this.props
// onError is required
onError(error, info)
}
render () {
const {children} = this.props
return React.Children.only(children)
}
}
export default ErrorBoundary