JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://fb.me/react-with-addons-0.11.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.11.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
JavaScript 1.7
/** @jsx React.DOM */
var Hello = React.createClass({
getInitialState: function() {
return {
elapsedTime: 0,
alarmSet: false,
alarmTime: 0
};
},
setAlarmTime: function() {
var time = 20;
console.log("setting alarmTime to: " + time);
this.setState({ alarmTime: time });
this.checkAlarm();
},
checkAlarm: function() {
console.log("but it's still: " + this.state.alarmTime);
this.setState({
alarmSet: this.state.alarmTime > 0 && this.state.elapsedTime < this.state.alarmTime
});
},
render: function() {
return <button onClick={this.setAlarmTime}>Hello {this.props.name}</button>;
}
});
React.renderComponent(<Hello name="World" />, document.body);