import React, { Component } from 'react'; import { Provider } from 'react-redux'; import { withRouter, Switch, Redirect, HashRouter, Route, BrowserRouter } from 'react-router-dom'; // Components import Contracts from 'containers/Tabs/Contracts'; import ENS from 'containers/Tabs/ENS'; import GenerateWallet from 'containers/Tabs/GenerateWallet'; import Help from 'containers/Tabs/Help'; import SendTransaction from 'containers/Tabs/SendTransaction'; import Swap from 'containers/Tabs/Swap'; import SignAndVerifyMessage from 'containers/Tabs/SignAndVerifyMessage'; import BroadcastTx from 'containers/Tabs/BroadcastTx'; import ErrorScreen from 'components/ErrorScreen'; // TODO: fix this interface Props { store: any; } interface State { error: Error | null; } export default class Root extends Component { public state = { error: null }; public componentDidCatch(error: Error) { this.setState({ error }); } public render() { const { store } = this.props; const { error } = this.state; if (error) { return ; } // key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395 const routes = (
); return ( {process.env.BUILD_DOWNLOADABLE ? ( {routes} ) : ( {routes} )} ); } } const LegacyRoutes = withRouter(props => { const { history } = props; const { pathname, hash } = props.location; if (pathname === '/') { switch (hash) { case '#send-transaction': case '#offline-transaction': history.push('/send-transaction'); break; case '#generate-wallet': history.push('/'); break; case '#swap': history.push('/swap'); break; case '#contracts': history.push('/contracts'); break; case '#ens': history.push('/ens'); break; case '#view-wallet-info': history.push('/account/info'); break; case '#check-tx-status': history.push('/check-tx-status'); break; } } return ( ); });