소스 검색

fix TagSelect prop value is an undefined

jim chen 8 년 전
부모
커밋
99f9e59bf5
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/components/TagSelect/index.js

+ 2 - 2
src/components/TagSelect/index.js

@@ -24,7 +24,7 @@ class TagSelect extends Component {
     value: this.props.value || this.props.defaultValue || [],
   };
   componentWillReceiveProps(nextProps) {
-    if ('value' in nextProps) {
+    if ('value' in nextProps && nextProps.value) {
       this.setState({ value: nextProps.value });
     }
   }
@@ -53,7 +53,7 @@ class TagSelect extends Component {
     const checkedTags = children
       .filter(child => this.isTagSelectOption(child))
       .map(child => child.props.value);
-    return checkedTags;
+    return checkedTags || [];
   }
 
   handleTagChange = (value, checked) => {