fuse-react
fuse-react copied to clipboard
Can't use fuse-react with React useState
Getting this error:
[email protected]:373 Uncaught (in promise) Invariant Violation: 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:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
Used this example: https://github.com/konbu310/hooks-and-fusebox
And modified index.tsx to:
import * as React from "react"; import * as ReactDOM from "react-dom"; import { UseStateSample } from "./components/UseStateSample"; import { Route, Switch } from "fuse-react"
ReactDOM.render(
@ost12666 so, you have pretty much answered to the issue yourself. How can I help? That's not fusebox
It started when I failed to use react router in my project because of strange error about failing to load prop-types. I then switched to fuse-react as a router. But then this error happened when I tried to use hooks. I ended up fixing all this by upgrading fro, fuse-box 3.7 to 4.0 to solve the prop-types problem and then using react router to solve the hooks problem. So I am good (except for several hours wasted) just wanted you to know...I love fuse-box!
@ost12666 good to know!!! btw v4 is coming to open test soon. There will be breaking changes, I will update all the issues, and notify everyone to help test the new product ;-)