-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
39 lines (31 loc) · 851 Bytes
/
index.tsx
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
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import './style/index.pcss';
import { AppContainer } from 'react-hot-loader';
import App from './component/app';
function renderApp(Comp) {
ReactDOM.hydrate(
<AppContainer>
<Comp />
</AppContainer>,
document.getElementById('app'),
);
}
window.onload = () => {
renderApp(App);
if (module.hot) {
let hmrKey;
/* tslint:disable no-submodule-imports */
const hotClient = require('webpack-hot-middleware/client');
hotClient.subscribe((e) => {
if (e.action === 'bundled') {
if (hmrKey && (hmrKey !== e.hmrKey)) {
window.location.reload();
} else {
hmrKey = e.hmrKey;
}
}
});
module.hot.accept('./component/app', () => renderApp(require('./component/app').default));
}
};