-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
51 lines (43 loc) · 1.15 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
/** @jsx React.DOM */
var Timer = require('./famous/utilities/Timer');
var React = require('react');
var ReactFamous = require('./react-famous');
var Context = ReactFamous.Context;
var Image = ReactFamous.Image;
var FamousTimerMixin = {
componentWillMount: function() {
this._famousTimers = [];
},
setInterval: function() {
this._famousTimers.push(
Timer.setInterval.apply(Timer, arguments)
);
},
componentWillUnmount: function() {
this._famousTimers.forEach(Timer.clear.bind(Timer));
}
};
var App = React.createClass({
mixins: [FamousTimerMixin],
getInitialState: function() {
return {famous: true};
},
componentDidMount: function() {
this.setInterval(this.toggle, 1000);
},
toggle: function() {
this.setState({famous: !this.state.famous});
},
render: function() {
var imageUrl = this.state.famous ? 'famous_logo.png' : 'react_logo.png';
return (
<Context>
<Image size={[200, 200]} content={imageUrl} />
</Context>
);
}
});
React.renderComponent(App(), document.body);
//Timer.setTimeout(function() {
// React.renderComponent(<h1>PEACE</h1>, document.body);
//}, 5000);