-
Hi there! In my implementation, I opted for adding another status called 'revalidating' that basically allowed the cache refetch without suspending, but also provide information that the current value was now stale (and render some sort of pending state). How would you handle this use case? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
Oh that's interesting. Does it differ in any other significant ways besides the "revalidating" status? If not, it might be worth switching to this one 😄
I don't think I have a need to differentiate between pending and "revalidating" as you call it– at least from an external "status" standpoint. For the component(s) suspending to fetch the data, their behavior is controlled by whether the update is a transition or not. So the only difference...I think...would be if you wanted to show some different UI treatment between the first load and a reload? |
Beta Was this translation helpful? Give feedback.
-
By "not suspend the component" do you mean "not show a fallback" or do you literally mean "not re-render the component"? I assume you mean the first thing, which you can do by scheduling an update as a transition ( |
Beta Was this translation helpful? Give feedback.
-
I have a solid lead on this (see this comment: #7 (comment)) Here's a walk through with a demo: |
Beta Was this translation helpful? Give feedback.
-
Okay I think this thread can be "answered" now. The general purpose answer for React is: Use a transition ( The specific answer for this package is: Use the new mutation hook ( |
Beta Was this translation helpful? Give feedback.
Okay I think this thread can be "answered" now.
The general purpose answer for React is: Use a transition (
useTransition
orstartTransition
).The specific answer for this package is: Use the new mutation hook (
useCacheMutation
) as shown in the "mutating cache values" example page.