rsnext/packages/next/client/error-boundary.ts
2019-03-18 18:08:51 +01:00

10 lines
272 B
TypeScript

import React, {ErrorInfo} from 'react'
export class ErrorBoundary extends React.Component<{fn: (err: Error, info: ErrorInfo) => void}> {
componentDidCatch(err: Error, info: ErrorInfo) {
this.props.fn(err, info)
}
render() {
return this.props.children
}
}