Skip to content

Instantly share code, notes, and snippets.

@rkmax
Forked from dankins/gist:55462150fec4eedc2279
Created December 16, 2014 23:50
Show Gist options
  • Save rkmax/a1fecd38fbcb5fb65c78 to your computer and use it in GitHub Desktop.
Save rkmax/a1fecd38fbcb5fb65c78 to your computer and use it in GitHub Desktop.
var React = require('react'),
mui = require('material-ui')
;
var RadioButtonGroup = React.createClass({
propTypes: {
name: React.PropTypes.string,
onChange: React.PropTypes.func,
options: React.PropTypes.array
},
_onClick: function(val){
this.setState({
selected: val
});
if(this.props.onChange) this.props.onChange(val);
},
getValue: function(){
return this.state.selected;
},
render: function(){
var options = this.props.options.map(function(option){
var defaultChecked = this.props.defaultValue === option.value;
return <mui.RadioButton
name={this.props.name}
key={option.value}
value={option.value}
label={option.label}
defaultChecked={defaultChecked}
onClick={this._onClick.bind(this,option.value)}
/>
},this);
return (
<div className="mui-radio-button-group mui-radio-button-group--vertical ">
{options}
</div>
)
}
});
module.exports = RadioButtonGroup;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment