useSWRInfinite loses initialData
See original GitHub issueHi, with the deprecated useSWRPages
I were able to set initialData
(from my Next.js static props) and load only the next pages.
I’d like to do the same with the new useSWRInfinite
but if I set the initialData
, this is lost after the next load; here an example:
https://codesandbox.io/s/swr-infinite-initial-data-00qk4
I tried also to set initialSize: 0
but with no luck :\
In the meantime I’m chaining the initialData
with the result data
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to fix SWR to work correctly with initialData or fallbackData
I've been using the awesome data fetching library SWR (the same the same team behind Next.js, the React framework. SWR is a lightweight...
Read more >useSWRInfiniteでinitialDataが認識されない現象が発生
ライブラリのアップデートは大事。 参考. useSWRInfinite loses initialData · Issue #588 · vercel/swr. Related #next.js. Next.
Read more >API - SWR
SWR is a React Hooks library for data fetching. SWR first returns the data from cache (stale), then sends the fetch request (revalidate),...
Read more >Useswr mutate - SPLIT FINGER
lost ark maxroll honing calculator ... initialData option the initial state. ... @shuding Is there a way to locally update useSWRInfinite data?
Read more >Using SWR Bound Mutation Across Nextjs Pages with ...
Need help on using mutation with useSWRInfinite. EXPECTED. On my posts page, I used useSWRInfinite to do load posts with pagination. it ...
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
initialData
was renamed tofallbackData
in SWR 1.0 to avoid confusion. WithuseSWRInfinite
, if there’s no fetched result yet the fallback will be returned:It should return the following data when rendering:
And when loading the next page,
There will not be a
[page1, 2]
state.According to https://github.com/vercel/swr/pull/894#issuecomment-759645838, it is expected that SWR doesn’t store
initialData
into the cache.But I also understand that there are developers who expect that
initialData
is stored into the cache. The following is a test case that is based on #894, but it avoids sending a request for the first page. This returnsinitialData
from the fetcher function if the request is for the first page.It would be nice if this is helpful for you.