| 1 | // @enableTransitivelyFreezeFunctionExpressions |
| 2 | function Component(props) { |
| 3 | const {data, loadNext, isLoadingNext} = |
| 4 | usePaginationFragment(props.key).items ?? []; |
| 5 | |
| 6 | const loadMoreWithTiming = () => { |
| 7 | if (data.length === 0) { |
| 8 | return; |
| 9 | } |
| 10 | loadNext(); |
| 11 | }; |
| 12 | |
| 13 | useEffect(() => { |
| 14 | if (isLoadingNext) { |
| 15 | return; |
| 16 | } |
| 17 | loadMoreWithTiming(); |
| 18 | }, [isLoadingNext, loadMoreWithTiming]); |
| 19 | |
| 20 | const items = data.map(x => x); |
| 21 | |
| 22 | return items; |
| 23 | } |