Theme-ui: Invalid hook call: maybe issue with HOC?

Created on 12 Aug 2019  ยท  4Comments  ยท  Source: system-ui/theme-ui

Hello, I'm trying to use theme-ui along with creative Tim's material kit.
It uses a lot of HOC's which I think may be the issue... would that make sense?

I am getting the following error when I add gatsby-plugin-theme-ui or even try to wrap a themeprovider around any element. I tried wrapping a page then to narrow it down wrapping a simple

and keep getting this.

Thanks in advance for any help :)

ร—
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

Most helpful comment

For others ending up here.
The result of npm ls react was:

โ”œโ”€โ”€ [email protected] 
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”€ [email protected]

deleting node_modules and reinstalling won't work by itself
must also resolve in package-lock.json
(was a new project for me so I just deleted package-lock.json
before npm installing again)
The result of npm ls react is now:

โ”œโ”€โ”€ [email protected] 
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”€ [email protected]  deduped

where the second react is deduped, which resolves this
https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react

All 4 comments

woops reinstall node modules fixed

For others ending up here.
The result of npm ls react was:

โ”œโ”€โ”€ [email protected] 
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”€ [email protected]

deleting node_modules and reinstalling won't work by itself
must also resolve in package-lock.json
(was a new project for me so I just deleted package-lock.json
before npm installing again)
The result of npm ls react is now:

โ”œโ”€โ”€ [email protected] 
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”€ [email protected]  deduped

where the second react is deduped, which resolves this
https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react

running into this right now but i dont see theme-ui mentioned at all.

โ”œโ”€โ”ฌ @storybook/[email protected]
โ”‚ โ”œโ”€โ”ฌ @storybook/[email protected]
โ”‚ โ”‚ โ””โ”€โ”€ [email protected]  deduped
โ”‚ โ”œโ”€โ”ฌ @storybook/[email protected]
โ”‚ โ”‚ โ””โ”€โ”€ [email protected]  deduped
โ”‚ โ””โ”€โ”€ [email protected]  deduped
โ”œโ”€โ”ฌ @storybook/[email protected]
โ”‚ โ””โ”€โ”ฌ @storybook/[email protected]
โ”‚   โ””โ”€โ”ฌ @storybook/[email protected]
โ”‚     โ””โ”€โ”€ [email protected]  deduped
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”ฌ [email protected]
โ”‚   โ””โ”€โ”€ [email protected]  deduped
โ””โ”€โ”€ [email protected]

could this have something to do with the peerDependency or themeui /* jsx */ renderer?
https://github.com/system-ui/theme-ui/blob/master/packages/core/package.json#L23

seems like a glitch in the matrix. removing node_modules and reinstalling them fixed it together with gatspy cleanup ๐Ÿคทโ€โ™‚๏ธ.

Was this page helpful?
0 / 5 - 0 ratings