Skip to content

Commit 60709d9

Browse files
committedAug 30, 2023
Remove setState call from ErrorBoundary render function.
1 parent 8c319cc commit 60709d9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎packages/components/src/ErrorBoundary/ErrorBoundary.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,24 @@ class ErrorBoundaryPage extends React.Component<ErrorPageProps, ErrorPageState>
3232
return { hasError: true, error, historyState: history.state };
3333
}
3434

35-
render() {
35+
updateState = () => {
3636
if (this.state.historyState !== history.state) {
3737
this.setState({
3838
hasError: false,
3939
historyState: history.state,
4040
});
4141
}
42+
};
43+
44+
componentDidUpdate(): void {
45+
this.updateState();
46+
}
4247

48+
componentDidMount(): void {
49+
this.updateState();
50+
}
51+
52+
render() {
4353
if (this.state.hasError) {
4454
if (this.props.silent) {
4555
return null;

0 commit comments

Comments
 (0)
Please sign in to comment.