From ac5d713ae172ff4c12a47de24998fc253bc662a3 Mon Sep 17 00:00:00 2001 From: henrynguyen5 Date: Mon, 18 Sep 2017 02:31:52 -0400 Subject: [PATCH] Revert "Hot module reload fixes (#181)" This reverts commit b59298ec0e3f4a70c1b5aa4e128778d803793572. --- .babelrc | 47 ++++++++++++++------------------ common/components/Root/index.jsx | 37 +++++-------------------- common/index.jsx | 10 +++++-- common/routing/index.js | 9 ------ common/routing/index.jsx | 29 ++++++++++++++++++++ 5 files changed, 64 insertions(+), 68 deletions(-) delete mode 100644 common/routing/index.js create mode 100644 common/routing/index.jsx diff --git a/.babelrc b/.babelrc index 6c4a0cff..5ccd6b58 100644 --- a/.babelrc +++ b/.babelrc @@ -1,30 +1,25 @@ { - "plugins": [ - [ - "transform-runtime", - { - "helpers": false, - "polyfill": false, - "regenerator": true, - "moduleName": "babel-runtime" + "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"] } - ], - [ - "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 0837ddfd..a8a24b11 100644 --- a/common/components/Root/index.jsx +++ b/common/components/Root/index.jsx @@ -1,45 +1,22 @@ import React, { Component } from 'react'; import { Provider } from 'react-redux'; -import { Router, Redirect, Route } from 'react-router'; +import { Router } 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 + history: PropTypes.object, + routes: PropTypes.func }; render() { - const { store, history } = this.props; + const { store, history, routes } = this.props; + // key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395 return ( - + - - - - - - - - - - + {routes()} ); diff --git a/common/index.jsx b/common/index.jsx index a6ef8a73..17d8d599 100644 --- a/common/index.jsx +++ b/common/index.jsx @@ -8,13 +8,18 @@ import { render } from 'react-dom'; import { syncHistoryWithStore } from 'react-router-redux'; import { Root } from 'components'; -import { history } from './routing'; +import { Routing, history } from './routing'; import { store } from './store'; const renderRoot = Root => { let syncedHistory = syncHistoryWithStore(history, store); render( - , + , document.getElementById('app') ); }; @@ -25,5 +30,4 @@ 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 deleted file mode 100644 index 2d514a05..00000000 --- a/common/routing/index.js +++ /dev/null @@ -1,9 +0,0 @@ -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 new file mode 100644 index 00000000..e3b41a74 --- /dev/null +++ b/common/routing/index.jsx @@ -0,0 +1,29 @@ +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 }); +}