React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://npmcdn.com/react@latest/dist/react-with-addons.js"></script>
<script src="https://npmcdn.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var Hello = React.createClass({
getInitialState() {
return {
author8: 'male',
}
},
handleInput(e) {
var id = e.target.id
var val = e.target.value
this.setState({
[id]: val,
})
},
render: function() {
console.log(this.state)
return <div >
< input id = "author1"
onChange = {
this.handleInput
}
value = {
this.state.author1
}
/> < br / >
< input id = "author2"
onChange = {
this.handleInput
}
value = {
this.state.author2
}
/> < br / >
< input id = "author3"
onChange = {
this.handleInput
}
value = {
this.state.author3
}
/> < br / >
< input id = "author4"
onChange = {
this.handleInput
}
value = {
this.state.author4
}
/> < br / >
< input id = "author5"
onChange = {
this.handleInput
}
value = {
this.state.author5
}
/> < br / >
< input id = "author6"
onChange = {
this.handleInput
}
value = {
this.state.author6
}
/> < br / >
< input id = "authour7"
type = "checkbox"
onChange = {
this.handleInput
}
value = {
!this.state.author7
}
checked = {
this.state.author7
}
/> Checkbox<br/>
< input type = "radio"
id = "author8"
name = "gender"
value = "male"
onChange = {
this.handleInput
}
checked = {
this.state.author8 === 'male'
}
/> Male<br/ >
< input type = "radio"
id = "author8"
name = "gender"
value = "female"
onChange = {
this.handleInput
}
checked = {
this.state.author8 === 'female'
}
/> Female<br/ >
< input type = "radio"
id = "author8"
name = "gender"
...