TypeError: dispatcher.useSyncExternalStore is not a function

See original GitHub issue
TypeError: dispatcher.useSyncExternalStore is not a function

  19 |     const categorySlug = query.categorySlug
  20 | 
> 21 |     const addToCart = useCart((state) => state.addToCar
```t)

i am having this error when using zustand in component, how to fix this ? i am on nextjs, with react 18.1 package, being looking into website for this problem, but there is so less infomation about it.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
feuersteinercommented, Nov 10, 2022

thanks for the update @tuoxiansp

the root of the issue from my side is how react-babylon-js handles its internal component state (because it is not a purely react component, it is coupled with babylonjs).

my fix was simply to list the state higher up to the Babylon component, and passing the changes as props inside that component, it solved it for me.

example:

instead of :

state = useStore(someState)

return <Model props={state} />

it became :

state = useStore(someState)

return <BabylonJS>
 <Model props={state} />
</BabylonJS>

hope it helps

0reactions
kreslicommented, Dec 9, 2022

Met the same problem while using react-pixi-fiber.

Resolved: just upgrade the version of the react-reconciler from 0.26.2 to 0.29 .

Seems like React will use useSyncExternalStore from reconciler, but the old version of reconciler does not contain the useSyncExternalStore .

Also I noticed that zustand was using a shim for useSyncExternalStore. I guess it doesn’t work on the environment that contains both old and new versions of reconciler.

Same issue for me with react-pixi-fiber but above doesn’t fixed the issue for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: dispatcher.useSyncExternalStore is not ...
This happens because react-redux is not supported yet with React 18 (React and React Native). Downgrade react-redux to the previous version ...
Read more >
TypeError: dispatcher.useSyncExternalStore is not a function ...
Describe the bug I hit this error: TypeError: dispatcher.useSyncExternalStore is not a function. (In 'dispatcher.
Read more >
TypeError: dispatcher.useSyncExternalStore is not a function
Hi all, I think I'm going crazy, because I've been trying to debug this issue with the apollo client for ~an hour, and...
Read more >
React, how to fix the TypeError: resolver is not a function error
Turned out the solution was very simple. I was doing some editing and I commented out the default export to component of the...
Read more >
Nextjs and React PDF Tutorial: WATCH THIS BEFORE ...
useSyncExternalStore is not a function PDFDownloadLink TypeError : ... work only work when render but hit error when reload page dispatcher.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found