Storing initialData in cache
See original GitHub issueHello,
I have a use-case where I would like to take advantage of the swr
built-in cache and store the initialData
there.
I found out I can use the cache module e.g.:
import { cache } from 'swr';
cache.set('my-key', initialData);
But I am wondering if there is any other, preferred way of achieving this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Initial Query Data | TanStack Query Docs
There are many ways to supply initial data for a query to the cache before ... once when the query is initialized, saving...
Read more >How to fix SWR to work correctly with initialData or fallbackData
SWR is a lightweight library that makes remote data fetching, caching or refetching data easier, exposing this via a React hook. The basic...
Read more >Interacting with cached data - Apollo GraphQL Docs
The readFragment method enables you to read data from any normalized cache object that was stored as part of any query result. Unlike...
Read more >Cached data or Using storage in flutter? - Stack Overflow
I have a backend server with graphql. And on flutter startup, I call query to backend for initial data. This initial data needs...
Read more >Storing local data with Apollo Client | by Eugenia Zigisova
Setting initial data. To make Graphql query work, Apollo Cache needs to expose it. To set local state fields to the cache typePolicies...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have the same issue as @zomars and use this workaround for now. Maybe it is helpful for others.
It basically sets the value of
initialData
into the cache on the first render, if the cache is empty for this key.Do you see this ever becoming a feature? e.g.