Replies: 4 comments
-
@ddhp |
Beta Was this translation helpful? Give feedback.
-
Hi @koba04, thanks for your reply! I think we want to keep the original data when the key changes and meanwhile the page/component supports SSR. |
Beta Was this translation helpful? Give feedback.
-
The dialog is a case that has the fallback data only for the initial fetch, so it's different from this. |
Beta Was this translation helpful? Give feedback.
-
Hmm.. I can't get it here. For our scenario, we have a fallback data for the initial fetch, then there is a key change caused by changing page but we can't see the hook getting revalidated. From my understanding, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
Description / Observed Behavior
If setting
revalidateIfStale
false andkeepPreviousData
true, changing between pages with fallback data wouldn't work.Expected Behavior
returning fallback data from SSR
Repro Steps / Code Example
Reproduce codesandbox: navigating between
/a
and/b
and swr hook always return old data.I think it's from here
swr/core/use-swr.ts
Lines 206 to 216 in f7004ac
when
revalidateIfStale
is false, cachedData wouldn't be updated from fallback and whenkeepPreviousData
is true, laggyRef data will be returned.if modifies returnedData to
will solve the problem but I don't know if this is the expect behavior.
Please help to clarify, thanks!
Additional Context
tested on
swr v2.0.3
next v13.1.6
Beta Was this translation helpful? Give feedback.
All reactions