Skip to content

Commit b3ea63f

Browse files
committed
Resolve error when gohome button is clicked
1 parent a545beb commit b3ea63f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/components/error/CrashErrorScreen.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ import ErrorScreenTemplate from './ErrorScreenTemplate';
44
import { undrawBugFixing } from '../../static/images';
55
import { useHistory } from 'react-router-dom';
66

7-
export type CrashErrorScreenProps = {};
7+
export type CrashErrorScreenProps = {
8+
onResolve: () => void;
9+
};
810

9-
function CrashErrorScreen(props: CrashErrorScreenProps) {
11+
function CrashErrorScreen({ onResolve }: CrashErrorScreenProps) {
1012
const history = useHistory();
1113
return (
1214
<ErrorScreenTemplate
1315
image={undrawBugFixing}
1416
message="엇! 오류가 발생했습니다."
1517
buttonText="홈으로"
16-
onButtonClick={() => history.push('/')}
18+
onButtonClick={() => {
19+
history.push('/');
20+
onResolve();
21+
}}
1722
/>
1823
);
1924
}

src/components/error/ErrorBoundary.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ class ErrorBoundary extends React.Component {
2323
Sentry.captureException(error);
2424
}
2525
}
26+
27+
handleResolveError = () => {
28+
this.setState({
29+
hasError: false,
30+
});
31+
};
2632
render() {
2733
if (this.state.chunkError) {
2834
return <ChunkErrorScreen />;
2935
}
3036
if (this.state.hasError) {
31-
return <CrashErrorScreen />;
37+
return <CrashErrorScreen onResolve={this.handleResolveError} />;
3238
}
3339
return (
3440
<ErrorBoundaryWrapper hasError={this.state.hasError}>

0 commit comments

Comments
 (0)