diff --git a/front/packages/ui/src/fetch-infinite.tsx b/front/packages/ui/src/fetch-infinite.tsx index 413f4558..1ff4231e 100644 --- a/front/packages/ui/src/fetch-infinite.tsx +++ b/front/packages/ui/src/fetch-infinite.tsx @@ -65,7 +65,8 @@ export const InfiniteFetchList = ( query, placeholderCount = 2, incremental = false, - children, + Render, + Loader, layout, empty, divider = false, @@ -82,10 +83,8 @@ export const InfiniteFetchList = ( placeholderCount?: number; layout: Layout; horizontal?: boolean; - children: ( - item: Data extends Page ? WithLoading : WithLoading, - i: number, - ) => ReactElement | null; + Render: (props: { item: Data; index: number }) => ReactElement | null; + Loader: (props: { index: number }) => ReactElement | null; empty?: string | JSX.Element; incremental?: boolean; divider?: boolean | ComponentType; @@ -111,9 +110,7 @@ export const InfiniteFetchList = ( if (incremental) items ??= oldItems.current; const count = items ? numColumns - (items.length % numColumns) : placeholderCount; - const placeholders = [...Array(count === 0 ? numColumns : count)].map( - (_, i) => ({ id: `gen${i}`, isLoading: true }) as Data, - ); + const placeholders = [...Array(count === 0 ? numColumns : count)].fill(null); const data = isFetching || !items ? [...(items || []), ...placeholders] : items; const List = nested ? (FlatList as unknown as typeof FlashList) : FlashList; @@ -137,7 +134,7 @@ export const InfiniteFetchList = ( }, ]} > - {children({ isLoading: false, ...item } as any, index)} + {item ? : } )} data={data} diff --git a/front/packages/ui/src/fetch-infinite.web.tsx b/front/packages/ui/src/fetch-infinite.web.tsx index 900d3a5f..61c33051 100644 --- a/front/packages/ui/src/fetch-infinite.web.tsx +++ b/front/packages/ui/src/fetch-infinite.web.tsx @@ -145,7 +145,7 @@ export const InfiniteFetchList = >; incremental?: boolean; placeholderCount?: number; layout: Layout; - children: ( - item: Data extends Page ? WithLoading : WithLoading, - i: number, - ) => ReactElement | null; + Render: (props: { item: Data; index: number }) => ReactElement | null; + Loader: (props: { index: number }) => ReactElement | null; empty?: string | JSX.Element; divider?: boolean | ComponentType; Header?: ComponentType<{ children: JSX.Element } & HeaderProps> | ReactElement; @@ -193,7 +192,7 @@ export const InfiniteFetchList = ( {Divider && i !== 0 && (Divider === true ?
: )} - {children({ isLoading: true } as any, i)} +
))} Header={Header} @@ -203,7 +202,7 @@ export const InfiniteFetchList = ( {Divider && i !== 0 && (Divider === true ?
: )} - {children({ ...item, isLoading: false } as any, i)} +
))}