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

Broken in NextJS 13 with React 18 #822

Closed
ricardomatias opened this issue Mar 30, 2023 · 6 comments
Closed

Broken in NextJS 13 with React 18 #822

ricardomatias opened this issue Mar 30, 2023 · 6 comments

Comments

@ricardomatias
Copy link

I'm getting an error with TypeError: maybeGetServerSnapshot is not a function when rendering a component that calls useStoreState:

TypeError: maybeGetServerSnapshot is not a function
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
getServerSnapshotWithSelector
file:/Users/feral/Projects/trendradar/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js (138:31)
Object.useSyncExternalStore
file:/Users/feral/Projects/trendradar/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5217:10)
useSyncExternalStore
file:/Users/feral/Projects/trendradar/node_modules/react/cjs/react.development.js (1676:21)
useSyncExternalStoreWithSelector
file:/Users/feral/Projects/trendradar/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js (145:15)
useStoreState
file:/Users/feral/Projects/trendradar/node_modules/easy-peasy/dist/index.cjs.js (66:25)

Using the latest React/NextJS and easy-peasy in Node v18.15.0

@jmyrland
Copy link
Collaborator

hey @ricardomatias - thanks for your report! We'll need to investigate this.

If you're able to create a small reproduction of this issue, it would be helpful in debugging this 👍 (we've got an example next app that you could clone)

@jmyrland
Copy link
Collaborator

I've bumped the versions of the example app, but I'm not able to reproduce the issue in this app.

However, I've been able to reproduce the issue in this sandbox (related to this SO post)

I'm not sure whats causing this issue, so we have to investigate this further.

jmyrland added a commit that referenced this issue Mar 31, 2023
@ricardomatias
Copy link
Author

I've bumped the versions of the example app, but I'm not able to reproduce the issue in this app.

However, I've been able to reproduce the issue in this sandbox (related to this SO post)

I'm not sure whats causing this issue, so we have to investigate this further.

I tried the example project that you referenced and it works fine. The only common information I could find on another project was this.

@jmyrland
Copy link
Collaborator

I think the changes in #823 might remedy this issue.

@ricardomatias could you install easy-peasy@5.2.1-alpha.0 to see if this fixes your issues?

@ricardomatias
Copy link
Author

The error is gone, thanks @jmyrland!

@jmyrland
Copy link
Collaborator

The error is gone, thanks @jmyrland!

Thanks for verifying 👍 I'll either publish a separate release with this change, or it will be a part of the upcoming v6-release.

Until then, you can just rely on the alpha release above.

jmyrland added a commit that referenced this issue Apr 17, 2023
* Bumps next example to use latest versions

* Maybe fixes #822?

* Adds nextjs ssr example

* Fix server rendering test

* Removes `getServerState`
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