mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 14:10:04 +02:00
remove value
validation in <RadioGroup>
it's redundant since we already require it in <Radio> propTypes
This commit is contained in:
parent
033093033a
commit
b3ee3b53ce
@ -8,7 +8,6 @@
|
|||||||
const first = require('lodash.first');
|
const first = require('lodash.first');
|
||||||
const isUndefined = require('lodash.isundefined');
|
const isUndefined = require('lodash.isundefined');
|
||||||
const get = require('lodash.get');
|
const get = require('lodash.get');
|
||||||
const invariant = require('invariant');
|
|
||||||
const Item = require('./item');
|
const Item = require('./item');
|
||||||
const find = require('lodash.find');
|
const find = require('lodash.find');
|
||||||
const classNames = require('classnames');
|
const classNames = require('classnames');
|
||||||
@ -27,11 +26,8 @@ const RadioGroup = React.createClass({
|
|||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return this.getState(this.props);
|
return this.getState(this.props);
|
||||||
},
|
},
|
||||||
componentWillMount: function() {
|
|
||||||
return this.checkValues(this.props);
|
|
||||||
},
|
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
return this.setState(this.checkValues(nextProps));
|
return this.setState(nextProps);
|
||||||
},
|
},
|
||||||
getState: function(props) {
|
getState: function(props) {
|
||||||
const _children = React.Children.toArray(props.children).filter((child) => {
|
const _children = React.Children.toArray(props.children).filter((child) => {
|
||||||
@ -65,13 +61,6 @@ const RadioGroup = React.createClass({
|
|||||||
checked
|
checked
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
checkValues: function(props) {
|
|
||||||
invariant(React.Children.toArray(props.children).every((child) => {
|
|
||||||
return (child.type.name !== 'Radio') ? true : !!child.props.value;
|
|
||||||
}), 'All <Radio> childs of <RadioGroup> must have a value property');
|
|
||||||
|
|
||||||
return props;
|
|
||||||
},
|
|
||||||
handleChange: function(key) {
|
handleChange: function(key) {
|
||||||
return (ev) => {
|
return (ev) => {
|
||||||
const {
|
const {
|
||||||
|
Loading…
Reference in New Issue
Block a user