Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.1.15-beta.0 regression in ssr with initialData: staleness thing doesnt refetch. works fine in 0.1.15 #230

Closed
iamstarkov opened this issue Jan 14, 2020 · 8 comments

Comments

@iamstarkov
Copy link

as described, will add a demo asap

iamstarkov added a commit to iamstarkov/swr that referenced this issue Jan 14, 2020
@iamstarkov
Copy link
Author

iamstarkov commented Jan 14, 2020

the problem is that in 0.1.16 initialData is behaving more or defaultData or fallbackData

workaround in the meantime:

const useFixedSWR = (key, fetcher, {initialData, ...config} = {}) => {
  const initial = React.useRef(initialData);
  React.useEffect(() => {
    if(key){
      initial.current = undefined;
    }
  }, [key]);
  return useSWR(key, fetcher, {...config, initialData: initial.current});
}

iamstarkov added a commit to iamstarkov/topics-manager that referenced this issue Jan 14, 2020
iamstarkov added a commit to iamstarkov/swr that referenced this issue Jan 14, 2020
@iamstarkov
Copy link
Author

the problem doesnt exist in 0.1.15

iamstarkov added a commit to iamstarkov/swr that referenced this issue Jan 14, 2020
@iamstarkov
Copy link
Author

iamstarkov commented Jan 14, 2020

Looks like regression was introduced in 0.1.15-beta.0

@iamstarkov iamstarkov changed the title 0.1.16 regression in ssr with initialData: staleness thing doesnt refetch. works fine in 0.1.15 0.1.15-beta.0 regression in ssr with initialData: staleness thing doesnt refetch. works fine in 0.1.15 Jan 14, 2020
@iamstarkov
Copy link
Author

this is the diff 0.1.15...v0.1.15-beta.0

@iamstarkov
Copy link
Author

#211 with #186 are both in the diff, so i dunno

aj-may added a commit to aj-may/swr that referenced this issue May 12, 2020
It appears some time ago the `initialData` configuration was used as a fallback.  When vercel#211 was merged, this behavior changed to be used with SSR like in the next.js example in the README.  Issue vercel#230 explains this was the expectation. I'm using SSR, so im fine with the new behavior.

Since `initialData` is now not quickly revalidated, another issue (vercel#308) has been raised.  Since `initialData` is not cached, and the mutate w/ callback grabs the curerent data from the cache, when `initialData` is used, `undefined` is returned.

fixes vercel#308
aj-may added a commit to aj-may/swr that referenced this issue May 22, 2020
It appears some time ago the `initialData` configuration was used as a fallback.  When vercel#211 was merged, this behavior changed to be used with SSR like in the next.js example in the README.  Issue vercel#230 explains this was the expectation. I'm using SSR, so im fine with the new behavior.

Since `initialData` is now not quickly revalidated, another issue (vercel#308) has been raised.  Since `initialData` is not cached, and the mutate w/ callback grabs the curerent data from the cache, when `initialData` is used, `undefined` is returned.

fixes vercel#308
aj-may added a commit to aj-may/swr that referenced this issue May 29, 2020
It appears some time ago the `initialData` configuration was used as a fallback.  When vercel#211 was merged, this behavior changed to be used with SSR like in the next.js example in the README.  Issue vercel#230 explains this was the expectation. I'm using SSR, so im fine with the new behavior.

Since `initialData` is now not quickly revalidated, another issue (vercel#308) has been raised.  Since `initialData` is not cached, and the mutate w/ callback grabs the curerent data from the cache, when `initialData` is used, `undefined` is returned.

fixes vercel#308
@sambokai
Copy link

sambokai commented Jun 5, 2020

I think this issue is not well formatted and described. It might make sense to open a new one with a concise description and not clutter it with references.

@iamstarkov
Copy link
Author

I dont agree that is "not well formatted and described". Following sentence describes the problem perfectly:

the problem is that in 0.1.16 initialData is behaving more or defaultData or fallbackData

in regards to reference, I dont control em

@huozhi
Copy link
Member

huozhi commented Jun 28, 2021

could you try the solution posted in #284 (comment) ?
Will close this issue as it seems to be reoslved with swr@beta, feel free to comment or reopen if you have any further issues

@huozhi huozhi closed this as completed Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants