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

Error: Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering. #1023

Closed
crapthings opened this issue Jun 21, 2022 · 4 comments

Comments

@crapthings
Copy link

"zustand": "^4.0.0-rc.1"
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",

const loading = loginStore((state) => state.loading)

the issue remains the same after i revert to 4.0 beta3

@dai-shi
Copy link
Member

dai-shi commented Jun 21, 2022

Hmm, it should have fixed when reported in #886.
This looks different from #987.

Does anyone else have this issue?

@crapthings
Copy link
Author

crapthings commented Jun 21, 2022

this is log

Error: Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.
    at Object.useSyncExternalStore (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5074:11)
    at useSyncExternalStore (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/react/cjs/react.development.js:1674:21)
    at useSyncExternalStoreWithSelector (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:145:15)
    at useStore (file:///Users/monsterstep/dev/nextjs-playground/nextone/node_modules/zustand/esm/index.mjs:8:17)
    at useBoundStore (file:///Users/monsterstep/dev/nextjs-playground/nextone/node_modules/zustand/esm/index.mjs:14:51)
    at LoginPage (webpack-internal:///./components/admin-login.js:18:77)
    at renderWithHooks (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5471:16)
    at renderIndeterminateComponent (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5544:15)
    at renderElement (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5759:7)
    at renderNodeDestructive (/Users/monsterstep/dev/nextjs-playground/nextone/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5898:11)

image

image

image

@dai-shi
Copy link
Member

dai-shi commented Jun 21, 2022

I don't see anything unexpected in the screenshots.

Here, we have getServerSnapshot with a fallback to avoid the error.
https://github.com/pmndrs/zustand/blob/v4.0.0-rc.1/src/react.ts#L37

@dai-shi
Copy link
Member

dai-shi commented Jul 18, 2022

If you have further questions, please open a new discussion.

@dai-shi dai-shi closed this as completed Jul 18, 2022
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

2 participants