diff --git a/.babelrc b/.babelrc index 5ccd6b58..6c4a0cff 100644 --- a/.babelrc +++ b/.babelrc @@ -1,25 +1,30 @@ { - "plugins": [ - [ - "transform-runtime", { - "helpers": false, - "polyfill": false, - "regenerator": true, - "moduleName": "babel-runtime" - } - ], - ["module-resolver", { - "root": ["./common"], - "alias": { - "underscore": "lodash" - }, - "cwd": "babelrc" - }], - "react-hot-loader/babel"], - "presets": ["es2015", "react", "stage-0", "flow"], - "env": { - "production": { - "presets": ["react-optimize"] + "plugins": [ + [ + "transform-runtime", + { + "helpers": false, + "polyfill": false, + "regenerator": true, + "moduleName": "babel-runtime" } + ], + [ + "module-resolver", + { + "root": ["./common"], + "alias": { + "underscore": "lodash" + }, + "cwd": "babelrc" + } + ], + "react-hot-loader/babel" + ], + "presets": ["es2015", "react", "stage-0", "flow"], + "env": { + "production": { + "presets": ["react-optimize"] } + } } diff --git a/common/components/Root/index.jsx b/common/components/Root/index.jsx index a8a24b11..0837ddfd 100644 --- a/common/components/Root/index.jsx +++ b/common/components/Root/index.jsx @@ -1,22 +1,45 @@ import React, { Component } from 'react'; import { Provider } from 'react-redux'; -import { Router } from 'react-router'; +import { Router, Redirect, Route } from 'react-router'; import PropTypes from 'prop-types'; +import { App } from 'containers'; +import GenerateWallet from 'containers/Tabs/GenerateWallet'; +import ViewWallet from 'containers/Tabs/ViewWallet'; +import Help from 'containers/Tabs/Help'; +import Swap from 'containers/Tabs/Swap'; +import SendTransaction from 'containers/Tabs/SendTransaction'; +import Contracts from 'containers/Tabs/Contracts'; +import ENS from 'containers/Tabs/ENS'; export default class Root extends Component { static propTypes = { store: PropTypes.object, - history: PropTypes.object, - routes: PropTypes.func + history: PropTypes.object }; render() { - const { store, history, routes } = this.props; - // key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395 + const { store, history } = this.props; return ( - + - {routes()} + + + + + + + + + + ); diff --git a/common/index.jsx b/common/index.jsx index 17d8d599..a6ef8a73 100644 --- a/common/index.jsx +++ b/common/index.jsx @@ -8,18 +8,13 @@ import { render } from 'react-dom'; import { syncHistoryWithStore } from 'react-router-redux'; import { Root } from 'components'; -import { Routing, history } from './routing'; +import { history } from './routing'; import { store } from './store'; const renderRoot = Root => { let syncedHistory = syncHistoryWithStore(history, store); render( - , + , document.getElementById('app') ); }; @@ -30,4 +25,5 @@ if (module.hot) { module.hot.accept('reducers/index', () => store.replaceReducer(require('reducers/index').default) ); + module.hot.accept(); } diff --git a/common/routing/index.js b/common/routing/index.js new file mode 100644 index 00000000..2d514a05 --- /dev/null +++ b/common/routing/index.js @@ -0,0 +1,9 @@ +import { browserHistory } from 'react-router'; +import { useBasename } from 'history'; + +export const history = getHistory(); + +function getHistory() { + const basename = ''; + return useBasename(() => browserHistory)({ basename }); +} diff --git a/common/routing/index.jsx b/common/routing/index.jsx deleted file mode 100644 index e3b41a74..00000000 --- a/common/routing/index.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { browserHistory, Redirect, Route } from 'react-router'; -import { useBasename } from 'history'; -import { App } from 'containers'; -import GenerateWallet from 'containers/Tabs/GenerateWallet'; -import ViewWallet from 'containers/Tabs/ViewWallet'; -import Help from 'containers/Tabs/Help'; -import Swap from 'containers/Tabs/Swap'; -import SendTransaction from 'containers/Tabs/SendTransaction'; -import Contracts from 'containers/Tabs/Contracts'; -import ENS from 'containers/Tabs/ENS'; - -export const history = getHistory(); -export const Routing = () => - - - - - - - - - - ; - -function getHistory() { - const basename = ''; - return useBasename(() => browserHistory)({ basename }); -}