/
index.js
57 lines (48 loc) · 1.21 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
import Summation from './ui/summation';
class Index extends React.Component {
constructor(props) {
super(props);
this.handleXChange = this.handleXChange.bind(this);
this.handleYChange = this.handleYChange.bind(this);
this.state = {
x: 1,
y: 2
};
}
handleXChange(newValue) {
this.setState({ x: newValue });
}
handleYChange(newValue) {
this.setState({ y: newValue });
}
render() {
return (
<div>
<h1>Hello, World!</h1>
<samp>NODE_ENV = "{ process.env.NODE_ENV }"</samp>
<p>
<a href="/api/health">Health check</a>
</p>
<Summation
onXChange={ this.handleXChange }
onYChange={ this.handleYChange }
x={ this.state.x }
y={ this.state.y }
/>
</div>
);
}
}
const rootInstance = ReactDOM.render(
<Index />,
document.getElementById('reactRoot')
);
if (process.env.NODE_ENV !== 'production' && module.hot) {
require('react-hot-loader/Injection').RootInstanceProvider.injectProvider({
getRootInstances: function () {
// Help React Hot Loader figure out the root component instances on the page:
return [rootInstance];
}
});
}