Merge pull request #207 from MyEtherWallet/master-hmr-fix-revert
Revert "Hot module reload fixes (#181)"
This commit is contained in:
commit
4175da2e2e
47
.babelrc
47
.babelrc
|
@ -1,30 +1,25 @@
|
||||||
{
|
{
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
[
|
||||||
"transform-runtime",
|
"transform-runtime", {
|
||||||
{
|
"helpers": false,
|
||||||
"helpers": false,
|
"polyfill": false,
|
||||||
"polyfill": false,
|
"regenerator": true,
|
||||||
"regenerator": true,
|
"moduleName": "babel-runtime"
|
||||||
"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"]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,22 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { Router, Redirect, Route } from 'react-router';
|
import { Router } from 'react-router';
|
||||||
import PropTypes from 'prop-types';
|
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 {
|
export default class Root extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
store: PropTypes.object,
|
store: PropTypes.object,
|
||||||
history: PropTypes.object
|
history: PropTypes.object,
|
||||||
|
routes: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
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 (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store} key={Math.random()}>
|
||||||
<Router history={history} key={Math.random()}>
|
<Router history={history} key={Math.random()}>
|
||||||
<Route name="App" path="" component={App}>
|
{routes()}
|
||||||
<Route name="GenerateWallet" path="/" component={GenerateWallet} />
|
|
||||||
<Route
|
|
||||||
name="ViewWallet"
|
|
||||||
path="/view-wallet"
|
|
||||||
component={ViewWallet}
|
|
||||||
/>
|
|
||||||
<Route name="Help" path="/help" component={Help} />
|
|
||||||
<Route name="Swap" path="/swap" component={Swap} />
|
|
||||||
<Route
|
|
||||||
name="Send"
|
|
||||||
path="/send-transaction"
|
|
||||||
component={SendTransaction}
|
|
||||||
/>
|
|
||||||
<Route name="Contracts" path="/contracts" component={Contracts} />
|
|
||||||
<Route name="ENS" path="/ens" component={ENS} />
|
|
||||||
<Redirect from="/*" to="/" />
|
|
||||||
</Route>
|
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,13 +8,18 @@ import { render } from 'react-dom';
|
||||||
import { syncHistoryWithStore } from 'react-router-redux';
|
import { syncHistoryWithStore } from 'react-router-redux';
|
||||||
|
|
||||||
import { Root } from 'components';
|
import { Root } from 'components';
|
||||||
import { history } from './routing';
|
import { Routing, history } from './routing';
|
||||||
import { store } from './store';
|
import { store } from './store';
|
||||||
|
|
||||||
const renderRoot = Root => {
|
const renderRoot = Root => {
|
||||||
let syncedHistory = syncHistoryWithStore(history, store);
|
let syncedHistory = syncHistoryWithStore(history, store);
|
||||||
render(
|
render(
|
||||||
<Root history={syncedHistory} store={store} />,
|
<Root
|
||||||
|
key={Math.random()}
|
||||||
|
routes={Routing}
|
||||||
|
history={syncedHistory}
|
||||||
|
store={store}
|
||||||
|
/>,
|
||||||
document.getElementById('app')
|
document.getElementById('app')
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -25,5 +30,4 @@ if (module.hot) {
|
||||||
module.hot.accept('reducers/index', () =>
|
module.hot.accept('reducers/index', () =>
|
||||||
store.replaceReducer(require('reducers/index').default)
|
store.replaceReducer(require('reducers/index').default)
|
||||||
);
|
);
|
||||||
module.hot.accept();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 });
|
|
||||||
}
|
|
|
@ -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 = () =>
|
||||||
|
<Route name="App" path="" component={App}>
|
||||||
|
<Route name="GenerateWallet" path="/" component={GenerateWallet} />
|
||||||
|
<Route name="ViewWallet" path="/view-wallet" component={ViewWallet} />
|
||||||
|
<Route name="Help" path="/help" component={Help} />
|
||||||
|
<Route name="Swap" path="/swap" component={Swap} />
|
||||||
|
<Route name="Send" path="/send-transaction" component={SendTransaction} />
|
||||||
|
<Route name="Contracts" path="/contracts" component={Contracts} />
|
||||||
|
<Route name="ENS" path="/ens" component={ENS} />
|
||||||
|
<Redirect from="/*" to="/" />
|
||||||
|
</Route>;
|
||||||
|
|
||||||
|
function getHistory() {
|
||||||
|
const basename = '';
|
||||||
|
return useBasename(() => browserHistory)({ basename });
|
||||||
|
}
|
Loading…
Reference in New Issue