Do preloaded resources not get cached in v2.0.0? #2304
Unanswered
n-pandey-f5
asked this question in
Q&A
Replies: 2 comments 5 replies
-
We don't store the preload result in the cache store that you can see on the devtool. But the preload result is cached in another cache store and is used as the response for the same key of fetcher requests. |
Beta Was this translation helpful? Give feedback.
5 replies
-
I'm also using react-router and SWR's preload. I was surprised that this doesn't behave as I expected: // In route definition...
loader: () => preload("/users", fetcher),
// In component...
const {data: users} = useSWR("/users", fetcher); The component data is undefined at first, I guess, because the useSWR hook didn't grab the preloaded data or something. FWIW, this approach works: // In component...
const {data: users} = useSWR("/users", fetcher, {fallbackData: useLoaderData()}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to use the docs to prefetch data and show. When I run the preload function inside my Component's
useEffect
, it fetches the data but for some reason is not caching it.I have the SWR devtools installed and they show nothing was cached, or any history of an api request being sent.
I am calling this,
Could you provide some guidance as to why this would be happening?
Beta Was this translation helpful? Give feedback.
All reactions