Skip to content

Instantly share code, notes, and snippets.

@takaki
Last active November 21, 2019 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaki/51769f214c980f6f362463c7b7f38cd1 to your computer and use it in GitHub Desktop.
Save takaki/51769f214c980f6f362463c7b7f38cd1 to your computer and use it in GitHub Desktop.
var React = require('react');
var ReactDOM = require('react-dom');
var App = React.createClass({
render: function() {
return (
<div>
<label>value a</label>
<input type="radio" name="aradio" value="A" checked="checked" /> <br />
<label>value b</label>
<input type="radio" name="aradio" value="B" />
<hr />
<label>text input</label>
<input type="text" name="atext" value="" />
</div>
)
}
});
var App = React.createClass({
getInitialState: function() {
return {
radio: "a",
text: ""
}
},
render: function() {
return (
<div>
<label>value a</label>
<input type="radio" name="aradio" value="A" checked={this.state.radio === 'a'}
onChange={() => this.setState({radio: 'a'})}/> <br />
<label>value b</label>
<input type="radio" name="aradio" value="B" checked={this.state.radio === 'b'}
onChange={() => this.setState({radio: 'b'})}/>
<hr />
<label>text input</label>
<input type="text" name="atext" value={this.state.text}
onChange={(e) => this.setState({text: e.target.value})}/>
</div>
)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment