Skip to content

Commit 6744ecc

Browse files
committed
ref(react): Remove renderKey
1 parent 1ecb349 commit 6744ecc

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

packages/react/src/errorboundary.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export type ErrorBoundaryProps = {
88
showDialog?: boolean;
99
dialogOptions?: Sentry.ReportDialogOptions;
1010
fallback?: React.ReactNode;
11-
renderKey?: string | number;
1211
fallbackRender?(fallback: {
1312
error: Error | null;
1413
componentStack: string | null;
@@ -42,6 +41,9 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
4241
if (showDialog) {
4342
Sentry.showReportDialog(dialogOptions);
4443
}
44+
45+
// componentDidCatch is used over getDerivedStateFromError
46+
// so that componentStack is accessible through state.
4547
this.setState({ error, componentStack });
4648
}
4749

@@ -52,19 +54,6 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
5254
}
5355
}
5456

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-
6857
public componentWillUnmount(): void {
6958
const { error, componentStack } = this.state;
7059
const { onUnmount } = this.props;

0 commit comments

Comments
 (0)