Separated specification and implementation in TopErrorBoundary (#1031)

* Encapsulate SceneHistory. A little.

* Clean up TopErrorBoundary
This commit is contained in:
Kent Beck 2020-03-21 02:26:01 -07:00 committed by GitHub
parent f6b36519f1
commit 1e8cd2bd1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,10 @@ export class TopErrorBoundary extends React.Component<
localStorage: "",
};
render() {
return this.state.hasError ? this.errorSplash() : this.props.children;
}
componentDidCatch(error: Error) {
resetCursor();
const _localStorage: any = {};
@ -88,8 +92,7 @@ export class TopErrorBoundary extends React.Component<
);
}
render() {
if (this.state.hasError) {
private errorSplash() {
return (
<div className="ErrorSplash">
<div className="ErrorSplash-messageContainer">
@ -155,7 +158,4 @@ export class TopErrorBoundary extends React.Component<
</div>
);
}
return this.props.children;
}
}