forked from matthisk/es6console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
73 lines (61 loc) · 1.87 KB
/
main.js
File metadata and controls
73 lines (61 loc) · 1.87 KB
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
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import createStore from './store/createStore';
import AppContainer from './containers/AppContainer';
import Raven from 'raven-js';
// ========================================================
// Store Instantiation
// ========================================================
if (__PROD__) {
Raven
.config('https://830240a30b9d4229add8932a16a17096@sentry.io/101285')
.install();
}
// ========================================================
// Store Instantiation
// ========================================================
const initialState = window.___INITIAL_STATE__;
const store = createStore(initialState);
// ========================================================
// Render Setup
// ========================================================
const MOUNT_NODE = document.getElementById('root');
let render = () => {
const routes = require('./routes/index').default(store);
ReactDOM.render(
<AppContainer store={store} routes={routes} />,
MOUNT_NODE
);
};
// This code is excluded from production bundle
if (__DEV__) {
if (module.hot) {
// Development render functions
const renderApp = render;
const renderError = (error) => {
const RedBox = require('redbox-react').default;
ReactDOM.render(<RedBox error={error} />, MOUNT_NODE);
};
// Wrap render in try/catch
render = () => {
try {
renderApp();
} catch (error) {
console.error(error);
renderError(error);
}
};
// Setup hot module replacement
module.hot.accept('./routes/index', () =>
setImmediate(() => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
render();
})
);
}
}
// ========================================================
// Go!
// ========================================================
render();