From faec7edc2b032da792e5f148cada39cf003b69de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 1 Dec 2017 17:19:41 +0800 Subject: [PATCH] Fix bug when TagSelectOption is 1 (#336) --- src/components/AvatarList/index.d.ts | 2 +- src/components/TagSelect/index.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/AvatarList/index.d.ts b/src/components/AvatarList/index.d.ts index 0f85f4ed..a6ca98ad 100644 --- a/src/components/AvatarList/index.d.ts +++ b/src/components/AvatarList/index.d.ts @@ -1,6 +1,6 @@ import React from "react"; export interface AvatarItemProps { - tips: string | React.ReactNode; + tips: React.ReactNode; src: string; } diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index 1c892965..5ce15693 100644 --- a/src/components/TagSelect/index.js +++ b/src/components/TagSelect/index.js @@ -39,7 +39,8 @@ class TagSelect extends Component { } getAllTags() { - const { children } = this.props; + let { children } = this.props; + children = React.Children.toArray(children); const checkedTags = children .filter(child => this.isTagSelectOption(child)) .map(child => child.props.value); @@ -86,7 +87,6 @@ class TagSelect extends Component { [styles.hasExpandTag]: expandable, [styles.expanded]: expand, }); - return (
{ - checkedTags && children - .map((child) => { + checkedTags && React.Children.map(children, (child) => { if (this.isTagSelectOption(child)) { return React.cloneElement(child, { key: `tag-select-${child.props.value}`, -- GitLab