From c598b364dd2808637b72cbdd9c644f910363ca5b Mon Sep 17 00:00:00 2001 From: zombieJ Date: Wed, 15 May 2019 11:12:55 +0800 Subject: [PATCH] fix: Update List ts definition (#16594) --- components/list/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/list/index.tsx b/components/list/index.tsx index a08b3661f7..417c5a0621 100644 --- a/components/list/index.tsx +++ b/components/list/index.tsx @@ -36,7 +36,7 @@ export interface ListProps { className?: string; style?: React.CSSProperties; children?: React.ReactNode; - dataSource: T[]; + dataSource?: T[]; extra?: React.ReactNode; grid?: ListGridType; id?: string; @@ -46,7 +46,7 @@ export interface ListProps { pagination?: PaginationConfig | false; prefixCls?: string; rowKey?: any; - renderItem: (item: T, index: number) => React.ReactNode; + renderItem?: (item: T, index: number) => React.ReactNode; size?: ListSize; split?: boolean; header?: React.ReactNode; @@ -124,6 +124,8 @@ export default class List extends React.Component, ListState> { renderItem = (item: any, index: number) => { const { renderItem, rowKey } = this.props; + if (!renderItem) return null; + let key; if (typeof rowKey === 'function') { @@ -170,7 +172,7 @@ export default class List extends React.Component, ListState> { loadMore, pagination, grid, - dataSource, + dataSource = [], size, rowKey, renderItem,