@@ -8,7 +8,6 @@ export type ErrorBoundaryProps = {
8
8
showDialog ?: boolean ;
9
9
dialogOptions ?: Sentry . ReportDialogOptions ;
10
10
fallback ?: React . ReactNode ;
11
- renderKey ?: string | number ;
12
11
fallbackRender ?( fallback : {
13
12
error : Error | null ;
14
13
componentStack : string | null ;
@@ -42,6 +41,9 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
42
41
if ( showDialog ) {
43
42
Sentry . showReportDialog ( dialogOptions ) ;
44
43
}
44
+
45
+ // componentDidCatch is used over getDerivedStateFromError
46
+ // so that componentStack is accessible through state.
45
47
this . setState ( { error, componentStack } ) ;
46
48
}
47
49
@@ -52,19 +54,6 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
52
54
}
53
55
}
54
56
55
- // If render key changes and there is an error, the component is reset.
56
- // This provides an easy way for users to reset their error boundary.
57
- public componentDidUpdate ( prevProps : ErrorBoundaryProps ) : void {
58
- const { error } = this . state ;
59
- const { renderKey, onReset } = this . props ;
60
- if ( error !== null && ! Object . is ( renderKey , prevProps . renderKey ) ) {
61
- if ( onReset ) {
62
- onReset ( this . state . error , this . state . componentStack ) ;
63
- }
64
- this . setState ( INITIAL_STATE ) ;
65
- }
66
- }
67
-
68
57
public componentWillUnmount ( ) : void {
69
58
const { error, componentStack } = this . state ;
70
59
const { onUnmount } = this . props ;
0 commit comments