Granular control over query keys #6362
Unanswered
ulvidamirli
asked this question in
Q&A
Replies: 1 comment 7 replies
-
are they all part of the queryKey? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While implementing filter on top of useInfiniteQuery, I encountered an unwanted behavior.
Let's say I have these filters in posts page: tag, location, sort.
And user visits the page with this shared URL:
www.example.com/posts?page=2
. And then filters posts by tag using UI.In this situation, it is expected the url params to change to
?page=1&tag=1
.But it changes to
?page=2&tag=1
.This also happens when there is more than two filters.
Since passing these filers to
queryKey
doesn't end up with the behavior I want, I want to set specific behaviors by functions. For example:I would like to refetch the query with specific parameters. But afaik, it is not possible.
I've tried to set a
urlParams
state and store/change all filters there. And typeurlParams
inqueryKey
array inside myuseInfiniteQuery
. Since I'm also controlling page param, this clashes withfetchNextPage()
. In this approach I also see the flash view of the initialData when I fetch next page or filter.I'm looking for a help. Much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions