import logo from './logo.svg';
import './App.css';
import useFetch from './hooks/useFetch';
import Button from '@mui/material/Button';
function App() {
const { data: dataFromBackend, loading } = useFetch('http://localhost:5000/api/test');
return (
<div className="App">
<header className="App-header">
{/* {dataFromBackend.message} */}
<br />
<Button>Ola Test</Button>
BasicButtons
</header>
</div>
);
}
export default App;
Uncaught runtime errors: × ERROR 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 See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem. Error: 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 See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem. at resolveDispatcher (http://localhost:3000/main.e654d662f5eb41baafa8.hot-update.js:12350:17) at Object.useContext (http://localhost:3000/main.e654d662f5eb41baafa8.hot-update.js:12356:24) at Button (http://localhost:3000/main.e654d662f5eb41baafa8.hot-update.js:3544:59) at renderWithHooks (http://localhost:3000/static/js/bundle.js:21482:22) at updateForwardRef (http://localhost:3000/static/js/bundle.js:24053:24) at beginWork (http://localhost:3000/static/js/bundle.js:26100:20) at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:11074:18) at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:11118:20) at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:11175:35) at beginWork$1 (http://localhost:3000/static/js/bundle.js:31049:11)
here is my package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "concurrently \"npm run backend\" \"npm run frontend\"",
"backend": "python ../backend/main.py",
"frontend": "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"
]
}
}
I already tried to update libraries, but without success
Hope you guys are able to help me...
Tried to update the packages, I'm expecting to be able tu utilize the Button component from '@mui/material/Button'
Update final answer:
I finally managed it, the most voted answer was enough, it's now working like a charm