React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
by etai
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var RadioGroup = React.createClass({
getInitialState: function(){
return {
checked: 'one'
};
},
onChange: function(id){
this.setState({checked: id});
alert('change to: ' + id);
},
render: function() {
return <div>
<label>
<input type='radio' name='radioGroup' id='one' checked={this.state.checked === 'one'} onChange={this.onChange.bind(this, 'one')}/>
<span>one</span>
</label>
<label>
<input type='radio' name='radioGroup' id='two' checked={this.state.checked === 'two'} onChange={this.onChange.bind(this, 'two')} />
<span>two</span>
</label>
</div>;
}
});
React.render(<RadioGroup />, document.getElementById('container'));