-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFILE
41 lines (33 loc) · 928 Bytes
/
FILE
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
"use strict";
class Foo extends StatebusComponent {
constructor(props) {
super(props);
}
componentWillMount() {
this.timer = setInterval(() => {
const val = Math.random();
console.log("Update foo", val);
this.statebus['/foo'] = val;
}, 1000);
}
render() {
if (!this.statebus['/foo']) {
return React.DOM.div({}, 'Loading!');;
}
console.log("Render", this.statebus['/foo']);
return React.DOM.div({
style: {
position: 'absolute',
top: 0,
bottom: '50%',
right: '50%',
left: 0,
backgroundColor: 'blue',
},
}, '' + this.statebus['/foo']);
}
componentWillUnmount() {
clearInterval(this.timer);
}
}
ReactDOM.render(React.createElement(Foo), document.body);