Skip to content

Commit 4175da2

Browse files
authored
Merge pull request #207 from MyEtherWallet/master-hmr-fix-revert
Revert "Hot module reload fixes (#181)"
2 parents 22ab3af + ac5d713 commit 4175da2

File tree

5 files changed

+64
-68
lines changed

5 files changed

+64
-68
lines changed

.babelrc

+21-26
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
{
2-
"plugins": [
3-
[
4-
"transform-runtime",
5-
{
6-
"helpers": false,
7-
"polyfill": false,
8-
"regenerator": true,
9-
"moduleName": "babel-runtime"
2+
"plugins": [
3+
[
4+
"transform-runtime", {
5+
"helpers": false,
6+
"polyfill": false,
7+
"regenerator": true,
8+
"moduleName": "babel-runtime"
9+
}
10+
],
11+
["module-resolver", {
12+
"root": ["./common"],
13+
"alias": {
14+
"underscore": "lodash"
15+
},
16+
"cwd": "babelrc"
17+
}],
18+
"react-hot-loader/babel"],
19+
"presets": ["es2015", "react", "stage-0", "flow"],
20+
"env": {
21+
"production": {
22+
"presets": ["react-optimize"]
1023
}
11-
],
12-
[
13-
"module-resolver",
14-
{
15-
"root": ["./common"],
16-
"alias": {
17-
"underscore": "lodash"
18-
},
19-
"cwd": "babelrc"
20-
}
21-
],
22-
"react-hot-loader/babel"
23-
],
24-
"presets": ["es2015", "react", "stage-0", "flow"],
25-
"env": {
26-
"production": {
27-
"presets": ["react-optimize"]
2824
}
29-
}
3025
}

common/components/Root/index.jsx

+7-30
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,22 @@
11
import React, { Component } from 'react';
22
import { Provider } from 'react-redux';
3-
import { Router, Redirect, Route } from 'react-router';
3+
import { Router } from 'react-router';
44
import PropTypes from 'prop-types';
5-
import { App } from 'containers';
6-
import GenerateWallet from 'containers/Tabs/GenerateWallet';
7-
import ViewWallet from 'containers/Tabs/ViewWallet';
8-
import Help from 'containers/Tabs/Help';
9-
import Swap from 'containers/Tabs/Swap';
10-
import SendTransaction from 'containers/Tabs/SendTransaction';
11-
import Contracts from 'containers/Tabs/Contracts';
12-
import ENS from 'containers/Tabs/ENS';
135

146
export default class Root extends Component {
157
static propTypes = {
168
store: PropTypes.object,
17-
history: PropTypes.object
9+
history: PropTypes.object,
10+
routes: PropTypes.func
1811
};
1912

2013
render() {
21-
const { store, history } = this.props;
14+
const { store, history, routes } = this.props;
15+
// key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395
2216
return (
23-
<Provider store={store}>
17+
<Provider store={store} key={Math.random()}>
2418
<Router history={history} key={Math.random()}>
25-
<Route name="App" path="" component={App}>
26-
<Route name="GenerateWallet" path="/" component={GenerateWallet} />
27-
<Route
28-
name="ViewWallet"
29-
path="/view-wallet"
30-
component={ViewWallet}
31-
/>
32-
<Route name="Help" path="/help" component={Help} />
33-
<Route name="Swap" path="/swap" component={Swap} />
34-
<Route
35-
name="Send"
36-
path="/send-transaction"
37-
component={SendTransaction}
38-
/>
39-
<Route name="Contracts" path="/contracts" component={Contracts} />
40-
<Route name="ENS" path="/ens" component={ENS} />
41-
<Redirect from="/*" to="/" />
42-
</Route>
19+
{routes()}
4320
</Router>
4421
</Provider>
4522
);

common/index.jsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ import { render } from 'react-dom';
88
import { syncHistoryWithStore } from 'react-router-redux';
99

1010
import { Root } from 'components';
11-
import { history } from './routing';
11+
import { Routing, history } from './routing';
1212
import { store } from './store';
1313

1414
const renderRoot = Root => {
1515
let syncedHistory = syncHistoryWithStore(history, store);
1616
render(
17-
<Root history={syncedHistory} store={store} />,
17+
<Root
18+
key={Math.random()}
19+
routes={Routing}
20+
history={syncedHistory}
21+
store={store}
22+
/>,
1823
document.getElementById('app')
1924
);
2025
};
@@ -25,5 +30,4 @@ if (module.hot) {
2530
module.hot.accept('reducers/index', () =>
2631
store.replaceReducer(require('reducers/index').default)
2732
);
28-
module.hot.accept();
2933
}

common/routing/index.js

-9
This file was deleted.

common/routing/index.jsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
import { browserHistory, Redirect, Route } from 'react-router';
3+
import { useBasename } from 'history';
4+
import { App } from 'containers';
5+
import GenerateWallet from 'containers/Tabs/GenerateWallet';
6+
import ViewWallet from 'containers/Tabs/ViewWallet';
7+
import Help from 'containers/Tabs/Help';
8+
import Swap from 'containers/Tabs/Swap';
9+
import SendTransaction from 'containers/Tabs/SendTransaction';
10+
import Contracts from 'containers/Tabs/Contracts';
11+
import ENS from 'containers/Tabs/ENS';
12+
13+
export const history = getHistory();
14+
export const Routing = () =>
15+
<Route name="App" path="" component={App}>
16+
<Route name="GenerateWallet" path="/" component={GenerateWallet} />
17+
<Route name="ViewWallet" path="/view-wallet" component={ViewWallet} />
18+
<Route name="Help" path="/help" component={Help} />
19+
<Route name="Swap" path="/swap" component={Swap} />
20+
<Route name="Send" path="/send-transaction" component={SendTransaction} />
21+
<Route name="Contracts" path="/contracts" component={Contracts} />
22+
<Route name="ENS" path="/ens" component={ENS} />
23+
<Redirect from="/*" to="/" />
24+
</Route>;
25+
26+
function getHistory() {
27+
const basename = '';
28+
return useBasename(() => browserHistory)({ basename });
29+
}

0 commit comments

Comments
 (0)