refetching with useInfiniteQuery #4569
Unanswered
nethalayaswanth
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
Uh oh!
There was an error while loading. Please reload this page.
-
apologise for bad formatting ,it's my first time writing in github
not sure whether solution lies in react-query or react,writing in the hope of any little thought would help me progress
useMessages hook which cache response corresponding to a particular
cursor
to[roomId, "messages"]
keyuseRoomMessages hook
which select data in the pages to be shown ( local pagination to limit the messages to render ,sort of list virtualisation) and flatten them into an arrayconst [pages,setPages]=useState(0)
QUESTION:
useRoomMessages hook is enabled when user click on a chat item. Initial page is loaded from cache while fetching it from backend.
sequentially all pages are fetched in background when user scrolled to them
NOW user switch to another chatRoom and revisit this room where initial page (0) from cache is shown.
no needing of refetching pages refetched in the first instance because the
socket events
ensure thedata is up to data
only the pages which are not fetched in first instance of hook and present in cache or pages not cached have to be fetched while scrolling
status like
dataUpdatedAt
foreach page of the query
would be helpful to validate the corresponding page from its the initial loading of the app so i can fetch data only that is absolutely stale or not present in cache .whilepreventing refetches of up to date data
Beta Was this translation helpful? Give feedback.
All reactions