()
| 1791 | } |
| 1792 | |
| 1793 | function MyComponent() { |
| 1794 | useTrackRenders() |
| 1795 | const fetchCountRef = React.useRef(0) |
| 1796 | const query = useInfiniteQuery({ |
| 1797 | queryFn: ({ pageParam }): Promise<Result> => |
| 1798 | sleep(10).then(() => ({ |
| 1799 | items: [...new Array(10)] |
| 1800 | .fill(null) |
| 1801 | .map((_, d) => pageParam * pageSize + d), |
| 1802 | nextId: pageParam + 1, |
| 1803 | prevId: pageParam - 1, |
| 1804 | ts: fetchCountRef.current++, |
| 1805 | })), |
| 1806 | getNextPageParam: (lastPage) => lastPage.nextId, |
| 1807 | initialPageParam: 0, |
| 1808 | queryKey: key, |
| 1809 | }) |
| 1810 | const data = React.use(query.promise) |
| 1811 | return ( |
| 1812 | <> |
| 1813 | {data.pages.map((page, index) => ( |
| 1814 | <React.Fragment key={page.ts}> |
| 1815 | <div> |
| 1816 | <div>Page: {index + 1}</div> |
| 1817 | </div> |
| 1818 | {page.items.map((item) => ( |
| 1819 | <p key={item}>Item: {item}</p> |
| 1820 | ))} |
| 1821 | </React.Fragment> |
| 1822 | ))} |
| 1823 | <button onClick={() => query.fetchNextPage()}>fetchNextPage</button> |
| 1824 | </> |
| 1825 | ) |
| 1826 | } |
| 1827 | |
| 1828 | function Page() { |
| 1829 | useTrackRenders() |
nothing calls this directly
no test coverage detected