JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://fb.me/react-with-addons-0.12.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
JavaScript 1.7
var Text1 = React.createClass({
render: function() {
var style = {};
if (!this.props.visible) {
style.display = 'none';
}
return <p style={style}>Hello</p>;
}
});
var Text2 = React.createClass({
render: function() {
var style = {};
if (!this.props.visible) {
style.display = 'none';
}
return <p style={style}>World</p>;
}
});
var Container = React.createClass({
getInitialState: function() {
return {count: 0};
},
componentDidMount: function() {
setInterval(this.updateCount, 1000);
},
updateCount: function() {
var nextCount = this.state.count + 1;
this.setState({count: nextCount});
},
render: function() {
return (
<div>
<Text1 visible={this.state.count % 2 == 0} />
<Text2 visible={this.state.count % 2 == 1} />
</div>
);
}
});
React.render(<Container />, document.body);