-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
33 lines (25 loc) · 768 Bytes
/
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
import history from 'shared/utils/history';
import IsomorphicRelay from 'isomorphic-relay';
import IsomorphicRouter from 'isomorphic-relay-router';
import React from 'react';
import ReactDOM from 'react-dom';
import './styles/app.css';
const data = JSON.parse(document.getElementById('preloadedData').textContent);
IsomorphicRelay.injectPreparedData(data);
const rootElement = document.getElementById('root');
function render() {
const routes = require('./routes').default;
ReactDOM.render(
<IsomorphicRouter.Router routes={routes} history={history} />,
rootElement
);
}
render();
if (module.hot) {
module.hot.accept('./routes', () => {
setTimeout(() => {
ReactDOM.unmountComponentAtNode(rootElement);
render();
});
});
}