Replies: 1 comment 1 reply
-
could you provide an example in codesandbox.io? |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Hello!
I am looking into migrating from swr to react-query and, after going through the documentation, there is one feature I would like to verify is possible before I commit to the massive refactor
To give some context, one of our use-cases is a live conversation list sorted by last message.
I'm trying to have a live infinite list, but I can't simply call refetch on all pages as:
Instead we have a "updatedAfter" parameter on the endpoint to only return the conversations that have been updated after the provided timestamp.
The way I currently think this can be done is by doing the following:
useInfiniteQuery
for the infinite list.useQuery
regularly call the partial update endpoint.useQuery
inqueryCache.setQueryData
using a key dedicated to partial updates.useQuery
. Note: I don't update the key to not cause an immediate re-render, and not spam the cache.useInfiniteQuery
andqueryCache.getQueryData
, remove duplicates, & resort.This all feels very hacky, would such a solution cause subtle bugs?
Would including a native solution for this use case be possible?
Beta Was this translation helpful? Give feedback.
All reactions