Browse Source

bugfix: NoticeIcon Tabs activeKey error (#5746)

pull/5866/head
Liu Ya 7 years ago
committed by 陈帅
parent
commit
a7fc2c79cc
  1. 54
      src/components/NoticeIcon/index.tsx

54
src/components/NoticeIcon/index.tsx

@ -88,34 +88,32 @@ export default class NoticeIcon extends Component<NoticeIconProps> {
if (!children) { if (!children) {
return null; return null;
} }
const panes = React.Children.map( const panes: ReactNodeArray = [];
children, React.Children.forEach(children, (child: React.ReactElement<NoticeIconTabProps>): void => {
(child: React.ReactElement<NoticeIconTabProps>): React.ReactNode => { if (!child) {
if (!child) { return;
return null; }
} const { list, title, count, tabKey, showClear, showViewMore } = child.props;
const { list, title, count, tabKey, showClear, showViewMore } = child.props; const len = list && list.length ? list.length : 0;
const len = list && list.length ? list.length : 0; const msgCount = count || count === 0 ? count : len;
const msgCount = count || count === 0 ? count : len; const tabTitle: string = msgCount > 0 ? `${title} (${msgCount})` : title;
const tabTitle: string = msgCount > 0 ? `${title} (${msgCount})` : title; panes.push(
return ( <TabPane tab={tabTitle} key={tabKey}>
<TabPane tab={tabTitle} key={title}> <NoticeList
<NoticeList clearText={clearText}
clearText={clearText} viewMoreText={viewMoreText}
viewMoreText={viewMoreText} data={list}
data={list} onClear={(): void => this.onClear(title, tabKey)}
onClear={(): void => this.onClear(title, tabKey)} onClick={(item): void => this.onItemClick(item, child.props)}
onClick={(item): void => this.onItemClick(item, child.props)} onViewMore={(event): void => this.onViewMore(child.props, event)}
onViewMore={(event): void => this.onViewMore(child.props, event)} showClear={showClear}
showClear={showClear} showViewMore={showViewMore}
showViewMore={showViewMore} title={title}
title={title} {...child.props}
{...child.props} />
/> </TabPane>,
</TabPane> );
); });
},
);
return ( return (
<> <>
<Spin spinning={loading} delay={300}> <Spin spinning={loading} delay={300}>

Loading…
Cancel
Save