var React = require('react');
var Radio = require('./index');
function getCheckedValue(children) {
var checkedValue = null;
children.forEach(function (radio) {
if (radio.props && radio.props.checked) {
checkedValue = radio.props.value;
}
});
return checkedValue;
}
var AntRadioGroup = React.createClass({
getDefaultProps: function () {
return {
prefixCls: 'ant-radio-group',
onChange: function () {
}
};
},
getInitialState: function () {
var props = this.props;
return {
value: props.value || props.defaultValue || getCheckedValue(props.children)
};
},
componentWillReceiveProps(nextProps) {
if ('value' in nextProps || getCheckedValue(nextProps.children)) {
this.setState({
value: nextProps.value || getCheckedValue(nextProps.children)
});
}
},
render: function () {
var props = this.props;
var children = props.children.map((radio) => {
if (radio.props) {
return