@@ -13,17 +13,35 @@ export type FixedForwardRef = < T, P = {} > (
13
13
) => ( props : P & React . RefAttributes < T > ) => React . ReactElement | null ;
14
14
const forwardRef = React . forwardRef as FixedForwardRef
15
15
16
- export type Props < ITEM > = {
16
+ export type VirtualListProps < ITEM > = {
17
+ /**
18
+ * Estimated average size of each list item.
19
+ */
17
20
itemSize ?: number ,
21
+ /**
22
+ * render space = list visible space + buffer x 2
23
+ */
18
24
buffer ?: number ,
25
+ /**
26
+ * List of items to render.
27
+ */
19
28
items : ITEM [ ] ,
29
+ /**
30
+ * Render function for each list item.
31
+ */
20
32
renderItem : ( item : ITEM , index : number ) => ReactNode ,
33
+ /**
34
+ * These items won't be removed when scroll. You can use css 'position:sticky' make them sticky.
35
+ */
21
36
persistentIndices ?: number [ ] , // index[]
22
37
className ?: string ,
23
38
style ?: React . CSSProperties ,
24
39
} & OptionalKeys < typeof defaultProps >
25
40
26
41
export const defaultProps = {
42
+ /**
43
+ * The visible space of the list. It is only used before DOM created(SSR).
44
+ */
27
45
listSize : 1000 ,
28
46
}
29
47
@@ -33,7 +51,7 @@ export interface VirtualListHandle {
33
51
}
34
52
35
53
export const VirtualList = forwardRef ( function < ITEM > (
36
- props : Props < ITEM > ,
54
+ props : VirtualListProps < ITEM > ,
37
55
ref : React . ForwardedRef < VirtualListHandle >
38
56
) {
39
57
const [ itemSize , setitemSize ] = useState ( props . itemSize || 100 ) ;
0 commit comments