SentryErrorBoundary.ts
1 import * as React from 'react' 2 3 interface Props { 4 children: React.ReactNode 5 } 6 7 interface State { 8 hasError: boolean 9 } 10 11 export class SentryErrorBoundary extends React.Component<Props, State> { 12 constructor(props: Props) { 13 super(props) 14 this.state = { hasError: false } 15 } 16 17 static getDerivedStateFromError(): State { 18 return { hasError: true } 19 } 20 21 render(): React.ReactNode { 22 if (this.state.hasError) { 23 return null 24 } 25 26 return this.props.children 27 } 28 }