[英]React Router Dom (v 6.4.3) page becomes unresponsive after navigation
My page is becoming unresponsive when I try to navigate using useNavigate or a Link in my component.当我尝试在我的组件中使用 useNavigate 或链接进行导航时,我的页面变得无响应。 After clicking a button or link, the url will change, and the javascript inside the target component will execute, but the page does not re-render.
点击按钮或链接后,url会发生变化,目标组件内部的javascript会执行,但页面不会重新渲染。 useNavigate works with other components in my app, so I'm not quite sure what the issue is.
useNavigate 与我的应用程序中的其他组件一起工作,所以我不太确定问题出在哪里。 Any input would be appreciated!
任何输入将不胜感激!
Dashboard.js:仪表板.js:
import { useNavigate, Link } from "react-router-dom";
const Dashboard = () => {
console.log("hello from dashboard");
let navigate = useNavigate();
return (
<div>
<Link className="pl-20" to="/test">
test
</Link>
</div>
);
};
export default Dashboard;
Test.js:测试.js:
import React from "react";
const Test = () => {
console.log("hello from test page");
return <div>this is the test page</div>;
};
export default Test;
App.js:应用程序.js:
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Dashboard from "./pages/Dashboard";
import Test from "./pages/Test";
function App() {
return (
<>
<Nav />
<Routes>
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/test" element={<Test />} />
</Routes>
</>
);
}
you gave pl-20 class on Dashboard.你在仪表板上输入了 pl-20 class。 but not on Test component.
但不在测试组件上。 Please check.
请检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.