-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
100 lines (82 loc) · 2.92 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Polyfills
import 'babel-polyfill';
import 'es6-promise/auto';
import 'isomorphic-fetch';
import './sources/internal/experimental/inject-custom-properties.js';
// Styles
//import 'sanitize.css/sanitize.css';
import './styles/index.scss';
import 'animate.css/animate.css';
import { Provider } from 'react-redux';
// Routing
import Redirect from 'react-router-dom/Redirect';
import Route from 'react-router-dom/Route';
import Switch from 'react-router-dom/Switch';
import createBrowserHistory from 'history/createBrowserHistory';
import ConnectedRouter from 'react-router-redux/ConnectedRouter';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
// Utils
import { hasReduxDevToolExtension } from './sources/internal/utils';
// Cofigurations
import configureStore from './sources/store';
// Main containers
import App from './sources/containers/App';
import DevTools from './sources/containers/DevTools';
import NotFound from './sources/containers/NotFound';
import routes from './sources/routes';
const history = createBrowserHistory({
});
const containerNode = document.getElementById('app');
const initialState = {};
const store = configureStore(initialState, history);
const render = () => {
ReactDOM.render(
<div>
<Provider store={ store }>
<MuiThemeProvider>
<ConnectedRouter history={ history }>
<App>
<Switch>
<Redirect from='/index.html' to='/' />
{
routes(store).map(({ path, exact, component, render }) =>
<Route key={ path } path={ path } exact={ exact } component={ component } render={ render } />
)
}
<Route component={ NotFound } />
</Switch>
</App>
</ConnectedRouter>
</MuiThemeProvider>
</Provider>
{ process.env.NODE_ENV !== 'production' && !hasReduxDevToolExtension ? <DevTools store={ store } /> : null }
</div>,
containerNode
);
};
if (module.hot) {
module.hot.accept([
'./sources/containers/App',
'./sources/reducers',
'./sources/routes'
], () => {
ReactDOM.unmountComponentAtNode(containerNode);
render();
});
}
render();
if (process.env.NODE_ENV !== 'production') {
// according this issue https://github.com/garbles/why-did-you-update/issues/45
let createClass = React.createClass;
Object.defineProperty(React, 'createClass', {
set: nextCreateClass => { createClass = nextCreateClass }
});
// disable noisy why did you update warnings
// eslint-disable-next-line global-require
// const { whyDidYouUpdate } = require('why-did-you-update');
// whyDidYouUpdate(React, { exclude: [ /^DevTools/, /^DockMonitor/, /^Route/, /^Router/ ] });
}
// Install ServiceWorker and AppCache
if (process.env.NODE_ENV === 'production') {
require('offline-plugin/runtime').install(); // eslint-disable-line global-require
}