24 lines
465 B
JavaScript
24 lines
465 B
JavaScript
// @enableTransitivelyFreezeFunctionExpressions
|
|
function Component(props) {
|
|
const {data, loadNext, isLoadingNext} =
|
|
usePaginationFragment(props.key).items ?? [];
|
|
|
|
const loadMoreWithTiming = () => {
|
|
if (data.length === 0) {
|
|
return;
|
|
}
|
|
loadNext();
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (isLoadingNext) {
|
|
return;
|
|
}
|
|
loadMoreWithTiming();
|
|
}, [isLoadingNext, loadMoreWithTiming]);
|
|
|
|
const items = data.map(x => x);
|
|
|
|
return items;
|
|
}
|