mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 03:08:30 +00:00
ErrorBoundary added
This commit is contained in:
parent
ace0f37074
commit
a314c2faed
@ -12,6 +12,9 @@ import { Notification } from '~/js/components/common/Notification';
|
|||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
|
|
||||||
const Wrapper = styled.div``;
|
const Wrapper = styled.div``;
|
||||||
|
const StyledH2 = styled(H2)`
|
||||||
|
padding: 20px 48px;
|
||||||
|
`;
|
||||||
|
|
||||||
const Receive = (props: Props) => {
|
const Receive = (props: Props) => {
|
||||||
const device = props.wallet.selectedDevice;
|
const device = props.wallet.selectedDevice;
|
||||||
@ -78,7 +81,7 @@ const Receive = (props: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<H2>Receive Ethereum or tokens</H2>
|
<StyledH2>Receive Ethereum or tokens</StyledH2>
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
{ ver }
|
{ ver }
|
||||||
<div className="value">
|
<div className="value">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import Select from 'react-select';
|
import Select from 'react-select';
|
||||||
import { H2 } from '~/js/components/common/Heading';
|
import { H2 } from '~/js/components/common/Heading';
|
||||||
import AdvancedForm from './AdvancedForm';
|
import AdvancedForm from './AdvancedForm';
|
||||||
@ -15,7 +16,6 @@ import { findToken } from '~/js/reducers/TokensReducer';
|
|||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
import type { Token } from '~/flowtype';
|
import type { Token } from '~/flowtype';
|
||||||
|
|
||||||
|
|
||||||
export default class SendContainer extends Component<Props> {
|
export default class SendContainer extends Component<Props> {
|
||||||
componentWillReceiveProps(newProps: Props) {
|
componentWillReceiveProps(newProps: Props) {
|
||||||
calculate(this.props, newProps);
|
calculate(this.props, newProps);
|
||||||
@ -33,6 +33,9 @@ export default class SendContainer extends Component<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const StyledH2 = styled(H2)`
|
||||||
|
padding: 20px 48px;
|
||||||
|
`;
|
||||||
|
|
||||||
const Send = (props: Props) => {
|
const Send = (props: Props) => {
|
||||||
const device = props.wallet.selectedDevice;
|
const device = props.wallet.selectedDevice;
|
||||||
@ -117,7 +120,7 @@ const Send = (props: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="send-form">
|
<section className="send-form">
|
||||||
<H2>Send Ethereum or tokens</H2>
|
<StyledH2>Send Ethereum or tokens</StyledH2>
|
||||||
<div className="row address-input">
|
<div className="row address-input">
|
||||||
<label>Address</label>
|
<label>Address</label>
|
||||||
<input
|
<input
|
||||||
|
@ -10,10 +10,7 @@ import styles from '~/styles/index.less';
|
|||||||
const root: ?HTMLElement = document.getElementById('root');
|
const root: ?HTMLElement = document.getElementById('root');
|
||||||
if (root) {
|
if (root) {
|
||||||
baseStyles();
|
baseStyles();
|
||||||
render(
|
render(<App />, root);
|
||||||
<App />,
|
|
||||||
root,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onbeforeunload = () => {
|
window.onbeforeunload = () => {
|
||||||
|
@ -5,6 +5,8 @@ import { Provider } from 'react-redux';
|
|||||||
import { ConnectedRouter } from 'react-router-redux';
|
import { ConnectedRouter } from 'react-router-redux';
|
||||||
import store, { history } from '../store';
|
import store, { history } from '../store';
|
||||||
|
|
||||||
|
import ErrorBoundary from '~/js/support/ErrorBoundary';
|
||||||
|
|
||||||
import LandingPageContainer from '../components/landing';
|
import LandingPageContainer from '../components/landing';
|
||||||
import WalletContainer from '../components/wallet';
|
import WalletContainer from '../components/wallet';
|
||||||
import BootloaderContainer from '../components/wallet/pages/Bootloader';
|
import BootloaderContainer from '../components/wallet/pages/Bootloader';
|
||||||
@ -29,19 +31,21 @@ const App = () => (
|
|||||||
<Route exact path="/import" component={LandingPageContainer} />
|
<Route exact path="/import" component={LandingPageContainer} />
|
||||||
<Route>
|
<Route>
|
||||||
<WalletContainer>
|
<WalletContainer>
|
||||||
<Route exact path="/settings" component={WalletSettingsContainer} />
|
<ErrorBoundary>
|
||||||
<Route exact path="/device/:device/" component={DashboardContainer} />
|
<Route exact path="/settings" component={WalletSettingsContainer} />
|
||||||
<Route exact path="/device/:device/network/:network" component={DashboardContainer} />
|
<Route exact path="/device/:device/" component={DashboardContainer} />
|
||||||
<Route exact path="/device/:device/acquire" component={AcquireContainer} />
|
<Route exact path="/device/:device/network/:network" component={DashboardContainer} />
|
||||||
<Route exact path="/device/:device/unreadable" component={UnreadableDeviceContainer} />
|
<Route exact path="/device/:device/acquire" component={AcquireContainer} />
|
||||||
<Route exact path="/device/:device/bootloader" component={BootloaderContainer} />
|
<Route exact path="/device/:device/unreadable" component={UnreadableDeviceContainer} />
|
||||||
<Route exact path="/device/:device/initialize" component={InitializeContainer} />
|
<Route exact path="/device/:device/bootloader" component={BootloaderContainer} />
|
||||||
<Route exact path="/device/:device/settings" component={DeviceSettingsContainer} />
|
<Route exact path="/device/:device/initialize" component={InitializeContainer} />
|
||||||
<Route exact path="/device/:device/network/:network/account/:account" component={SummaryContainer} />
|
<Route exact path="/device/:device/settings" component={DeviceSettingsContainer} />
|
||||||
<Route path="/device/:device/network/:network/account/:account/send" component={SendFormContainer} />
|
<Route exact path="/device/:device/network/:network/account/:account" component={SummaryContainer} />
|
||||||
<Route path="/device/:device/network/:network/account/:account/send/override" component={SendFormContainer} />
|
<Route path="/device/:device/network/:network/account/:account/send" component={SendFormContainer} />
|
||||||
<Route path="/device/:device/network/:network/account/:account/receive" component={ReceiveContainer} />
|
<Route path="/device/:device/network/:network/account/:account/send/override" component={SendFormContainer} />
|
||||||
<Route path="/device/:device/network/:network/account/:account/signverify" component={SignVerifyContainer} />
|
<Route path="/device/:device/network/:network/account/:account/receive" component={ReceiveContainer} />
|
||||||
|
<Route path="/device/:device/network/:network/account/:account/signverify" component={SignVerifyContainer} />
|
||||||
|
</ErrorBoundary>
|
||||||
</WalletContainer>
|
</WalletContainer>
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
25
src/js/support/ErrorBoundary.js
Normal file
25
src/js/support/ErrorBoundary.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
class ErrorBoundary extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch(error, info) {
|
||||||
|
// Display fallback UI
|
||||||
|
this.setState({ hasError: true });
|
||||||
|
// You can also log the error to an error reporting service
|
||||||
|
// logErrorToMyService(error, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) {
|
||||||
|
// You can render any custom fallback UI
|
||||||
|
return <div>Something went wrong.</div>;
|
||||||
|
}
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ErrorBoundary;
|
@ -1,6 +1,5 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
|
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
export const decimalToHex = (dec: number): string => new BigNumber(dec).toString(16);
|
export const decimalToHex = (dec: number): string => new BigNumber(dec).toString(16);
|
||||||
|
Loading…
Reference in New Issue
Block a user