-
-
Notifications
You must be signed in to change notification settings - Fork 90
When using any observer method, react throws invalid hook call error (electron-webpack) #248
Comments
Thanks for filling the issue with proper reproduction. It is indeed strange behavior. It is crashing here and React dispatcher is not set at that point for some reason. Almost looks like the Electron itself would have multiple copies of React in memory, but that's a long shot. Line 10 in 8e60bea
At this point, it's probably better to create an issue with React itself. I don't think we are doing anything wrong here. |
Hi Fredy, So I would guess, that point 1 and 2 are not the problem. But when I add the observer or use any other method ( It is really strange behavior, I agree. |
Not sure really, personally I don't use HMR because it's usually root of weird problems. However, I don't think it's this case because I tried I tried to debug more deeply into React. I am no expert, but for some reason, the Sorry, it's out of my expertise. React team might have some ideas hopefully, so please open the issue with them. |
I switched from electron-webpack to electron forge starter template and it works now. So I think the problem has sth. to do with electron-webpack. Thank you for your help! |
I fixed this issue by applying this: react-dnd/react-dnd#1566 (comment) Basically add this to
And add this to the file
|
Uh oh!
There was an error while loading. Please reload this page.
I try to build an application with electron-webpack, mobx, react and mobx-react-lite.
Hooks work with this setup.
But when I wrap a component using hooks in an observer, or use any of the other methods (
useObserver
,<Observer />
) react fails with an "Invalid hook call" error.When you remove the observer from the component everything works fine.
So it seems like it is not a problem with electron-webpack and hooks.
I created a basic application with this error.
https://github.com/danielbischoff/electron-webpack-quick-start
(you can see my changes in the latest commit)
To run this application
The text was updated successfully, but these errors were encountered: