JSFiddle - React, Tailwind, and code Playground
by spicyj
HTML
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.8.0/react.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.8.0/JSXTransformer.js"></script>
JavaScript 1.7
/** @jsx React.DOM */
var Component = React.createClass({
getInitialState: function() {
return {v: 5};
},
getDefaultProps: function() {
return {v: 5};
},
update: function(v) {
this.setState({v: v});
this.setProps({v: v});
},
handleClick: function() {
this.update(7);
},
render: function() {
console.log("render!",
this.state.v,
this.props.v
);
return <div onClick={this.handleClick}>
State: {this.state.v}
Props: {this.props.v}
</div>;
}
});
console.log("START =====");
comp = React.renderComponent(<Component />, document.body);
comp.update(6);
console.log("STOP =====");