Skip to content
Permalink
Browse files

fix(bee-radio): children没有的时候加提示

  • Loading branch information...
liushaozhen committed Dec 28, 2018
1 parent 4a5f630 commit 96a32f8d3e612524d5993eea7c48966240c50304
Showing with 57 additions and 25 deletions.
  1. +19 −8 build/RadioGroup.js
  2. +19 −8 dist/demo.js
  3. +1 −1 dist/demo.js.map
  4. +1 −1 package.json
  5. +17 −7 src/RadioGroup.js
@@ -70,17 +70,31 @@ var RadioGroup = function (_React$Component) {

var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));

_this.getValues = function () {
var array = [];
var children = _this.props.children;
if (!children) {
console.error('RadioGroup must have child nodes');
return array;
}
if (children.length > 1) {
children.map(function (item) {
array.push(item.props.value);
});
} else {
array.push(children.props.value);
}
return array;
};

_this.state = {
focusvalue: ''
};
return _this;
}

RadioGroup.prototype.componentDidMount = function componentDidMount() {
var array = [];
this.props.children.map(function (item) {
array.push(item.props.value);
});
var array = this.getValues();
if (array.indexOf(this.props.selectedValue) == -1) {
this.setState({
focusvalue: array[0]
@@ -89,10 +103,7 @@ var RadioGroup = function (_React$Component) {
};

RadioGroup.prototype.componentWillReceiveProps = function componentWillReceiveProps() {
var array = [];
this.props.children.map(function (item) {
array.push(item.props.value);
});
var array = this.getValues();
if (array.indexOf(this.props.selectedValue) == -1) {
this.setState({
focusvalue: array[0]

Some generated files are not rendered by default. Learn more.

Large diffs are not rendered by default.

@@ -1,6 +1,6 @@
{
"name": "bee-radio",
"version": "1.0.7",
"version": "1.0.8",
"description": "radio ui component for react",
"keywords": [
"react",
@@ -52,11 +52,24 @@ class RadioGroup extends React.Component {
}
}

componentDidMount(){
getValues = ()=>{
let array = []
this.props.children.map((item)=>{
let children = this.props.children;
if(!children){
console.error('RadioGroup must have child nodes');
return array;
}
if(children.length>1){
children.map((item)=>{
array.push(item.props.value)
})
})
}else{
array.push(children.props.value);
}
return array;
}
componentDidMount(){
let array = this.getValues();
if(array.indexOf(this.props.selectedValue)==-1){
this.setState({
focusvalue:array[0]
@@ -65,10 +78,7 @@ class RadioGroup extends React.Component {
}

componentWillReceiveProps(){
let array = []
this.props.children.map((item)=>{
array.push(item.props.value)
})
let array = this.getValues();
if(array.indexOf(this.props.selectedValue)==-1){
this.setState({
focusvalue:array[0]

0 comments on commit 96a32f8

Please sign in to comment.
You can’t perform that action at this time.