-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
index.js
45 lines (36 loc) · 941 Bytes
/
index.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
/* global document */
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import FPSStats from 'react-stats-zavatta';
class Root extends Component {
constructor(props) {
super(props);
this._appState = null;
}
_onAppStateChange(newState) {
this._appState = newState;
}
render() {
const {AppComponent} = this.props;
return (
<div>
<FPSStats isActive />
<AppComponent state={this._appState} onStateChange={this._onAppStateChange.bind(this)} />
</div>
);
}
}
// ---- Main ---- //
const container = document.createElement('div');
document.body.appendChild(container);
const render = () => {
const App = require('./app').default;
ReactDOM.render(<Root AppComponent={App} />, container);
};
render();
if (module.hot) {
module.hot.accept('./app', () => {
console.log('Hot reloading App component'); // eslint-disable-line
render();
});
}