Skip to content

atomWithStorage is broken with Gatsby-SSG in 1.8.1 #1377

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
jablonski opened this issue Aug 29, 2022 · 5 comments · Fixed by #1378
Closed

atomWithStorage is broken with Gatsby-SSG in 1.8.1 #1377

jablonski opened this issue Aug 29, 2022 · 5 comments · Fixed by #1378
Assignees

Comments

@jablonski
Copy link

Jotai 1.8.1 doesn't work in Gatsby (SSG) anymore, caused by latest changes for atomWithStorage (#1363). Project works fine with Jotai 1.8.0.

error "location" is not available during Server-Side Rendering. Enable "DEV_SSR" to debug this during "gatsby develop".
 540 |   const hashStorage = {
 541 |     getItem: (key2) => {
 542 |       const searchParams = new URLSearchParams(location.hash.slice(1));
 |   WebpackError: ReferenceError: location is not defined

@dai-shi
Copy link
Member

dai-shi commented Aug 29, 2022

Thanks for reporting and sorry for the regression. Let me work on it.

@dai-shi dai-shi self-assigned this Aug 29, 2022
@dai-shi
Copy link
Member

dai-shi commented Aug 29, 2022

(Hmm, I wonder why window.addEventListener hadn't caused any issues before.)

(I guess, in SSR, because useEffect won't fire.)

@dai-shi
Copy link
Member

dai-shi commented Aug 29, 2022

Can you please try https://ci.codesandbox.io/status/pmndrs/jotai/pr/1378 ?
Find "Local Install Instructions".

@jablonski
Copy link
Author

Thanks for the updated package, works without problems.

@jablonski
Copy link
Author

Just deployed 1.8.2, works perfectly. Thanks for the quick update!

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

Successfully merging a pull request may close this issue.

2 participants