'React - Error, Hookrouter invalid hook call
can't handle this error any suggestions?
import "./App.css";
import { navigate, useRoutes } from "hookrouter";
const routes = {
"/": () => <h1>home</h1>,
"/news": () => <h1>news</h1>,
};
function App() {
const page = useRoutes(routes);
return <div>{page || alert("not found")}</div>;
}
export default App;
this is app.js only this component exists nothing more then this also package.json and i think everything is okay but anyway returning invalid hook call but have no idea why
{
"name": "weather",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/hookrouter": "^2.2.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Solution 1:[1]
Have you tried to install the package before using it!
use this command to install the package
npm i hookrouter
//or if you're using yarn try this:
yarn add hookrouter
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Taghi Khavari |