Ritu Singh
Problem:
I want to make infinite scroll for my project. Currently, I'm using Javascript fetching API but want to apply react-query instead of.
React query is a form of Hook so can't be nested inside of useCallback.
How to solve this problem? I want to use react-query for better handling, with optimized way. and does query result of useQuery trigger re-render of the component?
Solution:
I'd suggest defining a query that takes the page number as a parameter, and then including that parameter in the query key. Then, whenever you update the page number, react-query will take care of automatically fetching the result. Here's a mock version I've sketched up:
RQInfiniteScrollTable.tsx
Suggested blogs:
>How to handle more than 100 cases neatly on Typescript?
>Type inference with 'as const' IN TypeScript
>Typescript Return argument: Tuple type or passed to rest parameter warning?
>How can you read a Blob in Deno in TypeScript?
>How to do Yup validation in form with TypeScript?
>How can I merge two arrays of objects that can be undefined in TypeScript?
>Javascript Error Solved: Property 'id' does not exist on type 'T'
>How to make sticky div remain stuck in JavaScript?
>How to manipulate manipulating Array object in JavaScript?