1
1
import React from 'react' ;
2
- import { IProps , HTMLDivProps , noop } from '@uiw/utils' ;
2
+ import { IProps , HTMLDivProps } from '@uiw/utils' ;
3
3
import { ListItem } from './Item' ;
4
4
import './style/index.less' ;
5
5
@@ -25,7 +25,7 @@ function InternalList<T>(props: ListProps<T>, ref: React.ForwardedRef<HTMLDivEle
25
25
noHover = false ,
26
26
active = false ,
27
27
size = 'default' ,
28
- renderItem = noop ,
28
+ renderItem,
29
29
className,
30
30
children,
31
31
header,
@@ -35,7 +35,7 @@ function InternalList<T>(props: ListProps<T>, ref: React.ForwardedRef<HTMLDivEle
35
35
} = props ;
36
36
let items : React . ReactNode ;
37
37
if ( dataSource && dataSource . length > 0 ) {
38
- items = dataSource . map ( ( item : any , index : number ) => renderItem ! ( item , index ) ) ;
38
+ items = dataSource . map ( ( item : any , index : number ) => renderItem && renderItem ! ( item , index ) ) ;
39
39
} else {
40
40
items = children ;
41
41
}
@@ -68,11 +68,8 @@ function InternalList<T>(props: ListProps<T>, ref: React.ForwardedRef<HTMLDivEle
68
68
) ;
69
69
}
70
70
71
- const List = React . forwardRef < HTMLDivElement , ListProps < any > > ( InternalList ) ;
72
- type List = typeof List & {
73
- Item : typeof ListItem ;
74
- } ;
71
+ type ListComponent = React . FC < React . PropsWithRef < ListProps < any > > > & { Item : typeof ListItem } ;
72
+ const List : ListComponent = React . forwardRef < HTMLDivElement > ( InternalList ) as unknown as ListComponent ;
73
+ List . Item = ListItem ;
75
74
76
- ( List as List ) . Item = ListItem ;
77
-
78
- export default List as List ;
75
+ export default List ;
0 commit comments