Clear cache of useInfiniteQuery #5465
Unanswered
gabisanfilippo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have this request:
It brings me all the students who are in the process of school dropout.
On my page, there's a Tab component with the values 'MT', 'TE', and 'RT'. Every time the tab the user is on changes, the request will change, because according to these values the students to be rendered change. Here is my page:
As you can see,
filters
are the filters that I send in the request; changingcurrentTab
updates thetype
key offilters
to its respective value already mentioned.I used a
useEffect
that was watchingcurrentTab
and would remove the query in question. In desperation, I created another one looking at several keys (currentTab
,currentKey
,filters
), but that didn't work either.I tried to put the
useEffect
inside the hook, as I already mentioned:I also tested these things:
But nothing worked out.
In general, my problem is as follows:
If I just enter the page, don't scroll and keep changing tabs, the query is successfully removed. But if I trigger the
InfiniteScroll
component, some students appear in the wrong tab. Not all appear, it's like 8 to 15 students listed in the wrong tab. I already tested the request and it is bringing the students correctly, the problem is really with React-query.In this application, we have used infinite requests many times in the same way. Only in this case is it causing problems.
I'll leave here the code for
InfiniteScroll
(in case the problem is with it):How can I solve this?
Beta Was this translation helpful? Give feedback.
All reactions