Skip to content

immutable (beta): SWRGlobalState.get(cache) is undefined when using SSG #1376

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

Closed
hazae41 opened this issue Aug 24, 2021 · 1 comment · Fixed by #1377
Closed

immutable (beta): SWRGlobalState.get(cache) is undefined when using SSG #1376

hazae41 opened this issue Aug 24, 2021 · 1 comment · Fixed by #1377
Labels
bug Something isn't working

Comments

@hazae41
Copy link

hazae41 commented Aug 24, 2021

Bug report

Description / Observed Behavior

I encounter this error on build when using useSWRImmutable on a Server-Side Generated page (getStaticProps)

const { data } = useSWRImmutable(key, fetcher)

TypeError: Cannot read property '0' of undefined

This code seems to be the cause:

https://github.com/vercel/swr/blob/master/src/use-swr.ts#L46

const [
  EVENT_REVALIDATORS,
  STATE_UPDATERS,
  MUTATION_TS,
  MUTATION_END_TS,
  CONCURRENT_PROMISES,
  CONCURRENT_PROMISES_TS
] = SWRGlobalState.get(cache) as GlobalState

SWRGlobalState.get(cache) seems to be undefined in this case

Additional Context

[email protected]

@huozhi huozhi added the bug Something isn't working label Aug 24, 2021
@huozhi
Copy link
Member

huozhi commented Aug 24, 2021

@hazae41 Thanks for reporting and using the beta version of swr 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants