@@ -13,17 +13,35 @@ export type FixedForwardRef = < T, P = {} > (
1313) => ( props : P & React . RefAttributes < T > ) => React . ReactElement | null ;
1414const forwardRef = React . forwardRef as FixedForwardRef
1515
16- export type Props < ITEM > = {
16+ export type VirtualListProps < ITEM > = {
17+ /**
18+ * Estimated average size of each list item.
19+ */
1720 itemSize ?: number ,
21+ /**
22+ * render space = list visible space + buffer x 2
23+ */
1824 buffer ?: number ,
25+ /**
26+ * List of items to render.
27+ */
1928 items : ITEM [ ] ,
29+ /**
30+ * Render function for each list item.
31+ */
2032 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+ */
2136 persistentIndices ?: number [ ] , // index[]
2237 className ?: string ,
2338 style ?: React . CSSProperties ,
2439} & OptionalKeys < typeof defaultProps >
2540
2641export const defaultProps = {
42+ /**
43+ * The visible space of the list. It is only used before DOM created(SSR).
44+ */
2745 listSize : 1000 ,
2846}
2947
@@ -33,7 +51,7 @@ export interface VirtualListHandle {
3351}
3452
3553export const VirtualList = forwardRef ( function < ITEM > (
36- props : Props < ITEM > ,
54+ props : VirtualListProps < ITEM > ,
3755 ref : React . ForwardedRef < VirtualListHandle >
3856) {
3957 const [ itemSize , setitemSize ] = useState ( props . itemSize || 100 ) ;
0 commit comments