diff --git a/common/Root.tsx b/common/Root.tsx index a531d9a4..301ac050 100644 --- a/common/Root.tsx +++ b/common/Root.tsx @@ -12,6 +12,7 @@ import ViewWallet from 'containers/Tabs/ViewWallet'; import SignAndVerifyMessage from 'containers/Tabs/SignAndVerifyMessage'; import BroadcastTx from 'containers/Tabs/BroadcastTx'; import RestoreKeystore from 'containers/Tabs/RestoreKeystore'; +import ErrorScreen from 'components/ErrorScreen'; // TODO: fix this interface Props { @@ -19,11 +20,26 @@ interface Props { history: any; } -export default class Root extends Component { +interface State { + hasError: boolean; +} + +export default class Root extends Component { + public state = { + hasError: false + }; + + public componentDidCatch() { + this.setState({ hasError: true }); + } + public render() { const { store, history } = this.props; + const { hasError } = this.state; // key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395 - return ( + return hasError ? ( + + ) : (
@@ -35,10 +51,7 @@ export default class Root extends Component { - +
diff --git a/common/components/ErrorScreen/index.scss b/common/components/ErrorScreen/index.scss new file mode 100644 index 00000000..e840be61 --- /dev/null +++ b/common/components/ErrorScreen/index.scss @@ -0,0 +1,8 @@ +@import 'common/sass/variables'; +@import 'common/sass/mixins'; + +.ErrorScreen { + @include cover-message; + background: $brand-danger; + +} diff --git a/common/components/ErrorScreen/index.tsx b/common/components/ErrorScreen/index.tsx new file mode 100644 index 00000000..efb51165 --- /dev/null +++ b/common/components/ErrorScreen/index.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import './index.scss'; + +const SUBJECT = 'Error!'; +const DESCRIPTION = + 'I encountered an error while using MyEtherWallet. Here are the steps to re-create the issue: ...'; + +const ErrorScreen: React.SFC<{}> = () => { + return ( +
+
+

Oops!

+

Something went really wrong, so we're showing you this red error page! 😱

+

+ Please contact{' '} + + support@myetherwallet.com + {' '} + if a refresh doesn't fix it (or click it anyway to open a ticket 😊 ). +

+
+
+ ); +}; + +export default ErrorScreen;