Предупреждение: неверный вызов крючка. Крюки можно назвать только внутри тела
функционального компонента. 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
useref React
browserrouter Chunk-lsoulm7l.mjs: 8003 < /p>
< /blockquote>
import React, { useState, useEffect } from "react";
import { getAllMatches, getAllSeasons, getAllTeams } from "../services/api";
import StatsOverview from "../components/StatsOverView";
import MatchCountChart from "../components/MatchChart";
const Dashboard = () => {
const [totalStats, setTotalStats] = useState({ totalMatches: 0, totalTeams: 0, totalSeasons: 0 });
const [seasonMatches, setSeasonMatches] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchData = async () => {
// Fetch data logic...
};
fetchData();
}, []);
return (
Dashboard
);
};
export default Dashboard;
< /code>
app.js
// src/App.js
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Dashboard from './pages/Dashboard';
function App() {
return (
{/* You can add more routes below */}
);
}
export default App;
< /code>
package.json
"dependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^13.5.0",
"d3": "^7.9.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
Подробнее здесь: https://stackoverflow.com/questions/795 ... nction-com