MRT Grid Infinite scrolling with RTk Query #1115
Unanswered
Vigneshvaraa
asked this question in
Q&A
Replies: 2 comments
-
Sure, it's possible, but I'm not going to spend the time myself to make an example. This should not be opened as an issue since this is not a bug. Convert to discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@Vigneshvaraa Hello. Did you deal with this problem now? Maybe you can provide an example. I have the same issue. Thanks |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
material-react-table version
v2.12.1
react & react-dom versions
v18.2.0 & v18.2.0
Describe the bug and the steps to reproduce it
As per the documentation of MRT's Infinite Scroll (), it's using tanstack query with useInfiniteQuery to call api. I tried to replicate the same but we are using RTK query and that couldn't be called inside a queryFn. Is it possible to use RTK query for infinite scrolling in MRT? If so kindly share some examples.
Minimal, Reproducible Example - (Optional, but Recommended)
As Per Documentation:
const { data, fetchNextPage, isError, isFetching, isLoading } =
useInfiniteQuery({
queryKey: [
'table-data',
columnFilters, //refetch when columnFilters changes
globalFilter, //refetch when globalFilter changes
sorting, //refetch when sorting changes
],
queryFn: async ({ pageParam }) => {
const url = new URL(
'/api/data',
process.env.NODE_ENV === 'production'
? 'https://www.material-react-table.com'
: 'http://localhost:3000',
);
url.searchParams.set('start',
${(pageParam as number) * fetchSize}
);url.searchParams.set('size',
${fetchSize}
);url.searchParams.set('filters', JSON.stringify(columnFilters ?? []));
url.searchParams.set('globalFilter', globalFilter ?? '');
url.searchParams.set('sorting', JSON.stringify(sorting ?? []));
Expected:
Is it possible to achieve this with RTK query?
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms
Beta Was this translation helpful? Give feedback.
All reactions