facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
227.51k stars 46.42k forks source link

TypeError: dispatcher.useState is not a function #14027

Closed ericvicenti closed 5 years ago

ericvicenti commented 5 years ago

If you hit this error, you're trying to use hooks after upgrading react to 16.7, but you haven't upgraded react-dom to the same version!

The experience could be improved by checking for dispatcher.getState here https://github.com/facebook/react/blob/504576306461a5ff339dc99691842f0f35a8bf4c/packages/react/src/ReactHooks.js#L17, and throwing an error that explains your -dom package is out of date.

Closing because there is no real bug here, just hope somebody finds this useful

gaearon commented 5 years ago

Haha thanks

MichelDiz commented 5 years ago

I'm using react@next ("^16.7.0-alpha.0"), but with TypeScript and I hit this error oO

UPDATE: I believe my issue is because "react-konva" is not updated.

mistricky commented 5 years ago

Thx! I had similar problem

mp3 commented 5 years ago

I got this error when using Jest. and i update react-test-renderer then solved.

yarn add -D react-test-renderer@next

"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0",
"react-test-renderer": "^16.7.0-alpha.0",
damianobarbati commented 5 years ago

LOL: just stumbled on this. thanks @ericvicenti

corysimmons commented 5 years ago

More issues like this please! 😍

artivilla commented 5 years ago

Had a similar issue but I had to specify exact version 16.7.0-alpha.2 as a dep rather than the default ^16.7.0-alpha.2 that would resolve to 16.7.0 in my lockfile.