
[英]React router 6+ : how to strongly type the params option in route loader?
有路由器 有装载机export const loader: LoaderFunction = async ({ params }) => { return await fetchData(params.todoId); }; 如何根据路径键入参数? 等待路径中指定参数的突出显示。 更新 ...
[英]React router 6+ : how to strongly type the params option in route loader?
有路由器 有装载机export const loader: LoaderFunction = async ({ params }) => { return await fetchData(params.todoId); }; 如何根据路径键入参数? 等待路径中指定参数的突出显示。 更新 ...
[英]how to update fetch with useLoaderData() using react-router?
我想在提交表单后更新 useLoaderData() 的数据。 就我而言: <Route index element={<CoutriesList />} loader={countriesLoader} /> 在 CountriesList 元素上: const coun ...
[英]How to keep the navigation active when accessing nesting navigation with React Router?
有没有一种方法可以导航到嵌套路线并保持主导航处于活动状态? 例如,这是主导航http://localhost:3000/#/tractian/assets-list并且我从React Router获得了一个active class : 但是,如果我导航到嵌套路线,则 class 将被删除: ht ...
[英]React Component content is not rendering or not found
我是第一次使用 React 构建前端,并且刚刚添加了路由。 从那以后,页面不再正确呈现,我不知道错误在哪里。 查看时我go到首页路径组件内容似乎没有加载这是我的 App.js 和路线 这是我的 index.js 这是我的 home.js 我的 package.json{ "name": "test ...
[英]Prevent routing while user manually changes url in the browser - ReactJS
当用户在浏览器中手动更改 url 时,我想阻止路由。 我将"/main"作为我正在保护的管理路由,但是当用户更改其在本地存储中的角色并尝试访问“/main”时,问题就开始了。 我想阻止用户手动更改其 url 中的路线,或者如果他们手动更改则显示错误。 编辑:我在后端保护我的路线,但在前端我什至没有 ...
[英]useParams() is an empty object in react-router-dom v6.8
我只是想在 React 中使用react-router-dom v 6.8 从动态路由( "/articles/:articleId" )中检索参数"react-router-dom": "^6.8.0", "@types/react-router-dom": "^5.3.3", 我试着 ...
[英]Why am I not able to use "Routes" from react-router-dom even though it is version 6? It shows error
我一直在尝试从import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; -router-dom 中获取“路由”,就像这样我在这里称之为: 它抛出一个错误: export 'Routes' (imported ...
[英]React router Link not working when adding onClick handler to button inside the Link
我有一个表单,当用户按下提交按钮时,我希望对输入数据进行一些计算,然后将用户带到一个新页面。 应用程序.js 计算器.js 出于我不知道的原因,当 onClick 事件处理程序未附加到按钮时,链接有效,但当我添加 onClick 事件处理程序时,链接不再有效。 将 onClick 事件处理程序添加到 ...
[英]MUI Drawer with react-router-dom do not activate the transition effect
我想将像 MUI 网站中的示例那样的持久抽屉与 react-router-dom 结合起来。 我发现的唯一问题是过渡效果不再起作用,段落不会调整大小以为打开的抽屉腾出空间,因此后者最终会与文本重叠。 我已经设置了一个有效的 Codesandbox 示例传递给路由页面的 open 道具似乎没有激活这里 ...
[英]Building React app for production throwing error in the react router dom v6.4 library
该应用程序是使用 Vite 构建的,它是一个基于 React ts 的应用程序。 该项目在开发模式下正常运行,但是当尝试使用npm run build用于生产的应用程序时,出现以下错误。 我真的不想将 react-router-dom 版本降级到 6.4 以下 有人可以在这里指导我吗? 无法解决错误 ...
[英]Having issues using React Router 5
我无法理解如何正确使用 React Router。 我想要一个在根目录 ( "/" ) 呈现的组件有多个路由并默认重定向到"/projects" 。 我想要的路线是这些: "/projects" "/projects/project/:projectId/" "/projects/project/: ...
[英]React.js, How to fetch the properties in a URL pathname?
我正在尝试在我的 React 应用程序中使用match通过 URL 路径名获取 uid 和令牌。 但是我得到了错误: 未捕获的类型错误:n 未定义这是我的代码片段: 根据这个线程: https://stackoverflow.com/questions/70609785/uncaught-type ...
[英]Maintain context values between routes in React.js
我正在尝试在上下文中的路由之间维护 state 值。 但是当路线改变时它会被重置。 aackage.json: "react-router-dom": "^6.8.0", "react-dom": "^18.2.0", "react": "^18.2.0", 应用程序.js:export d ...
[英]My logo also get underlined while using activeClassName attribute in react.js
我正在使用activeClassName="active"来设置导航菜单项的样式,因此活动页面名称应该带有下划线。 唯一的问题是当用户在主页上时,徽标也会带有下划线/样式,而我希望导航菜单中的主页项目带有下划线或样式。 当我在活动页面上时,导航菜单中的每个页面名称都会设置样式,唯一的问题是当我在主页 ...
[英]<Link> with "react-router-dom 6.7.0"
我正在尝试创建我的第一个网站,但在重定向到另一个页面时遇到问题。 我将Routes添加到 App.jsx,并添加了到Navbar的链接; 单击Navbar中的“服务”转到"/services" ,但该页面不显示任何内容,仅显示Navbar 。 我也试过NavLink ,但它没有改变任何东西。 请帮 ...
[英]React app display blank page without any compilation error
我不确定下面我的 React 应用程序出了什么问题,它编译成功且没有错误,但不显示任何内容(只显示空白页)。 谁能指出我的代码出了什么问题? 对不起,我是新来的。 索引.js 应用程序.js 我的 Home.js 位于组件文件夹中文件夹结构如下 首页.js ...
[英]_ref is undefiend when using react-router-dom's Navlink component
在设置一个新的 React web 应用程序项目时,在安装react-router-dom v^6.8.0 之后,我使用从react-router-dom导入的NavLink的那一刻是这样的:<NavLink> <MyCustomJsx /> </NavLink&g ...
[英]Link in Material UI and React Router Dom
它需要看起来像 Material-UI 中的<Link > 但问题是它在导航时进行刷新。 所以我所做的是使用 react-router-dom 的<Link> Link> 并将 Material-UI 的<Link>作为其组件。 问题出在 UI 上,我想遵 ...
[英]component is not render, problems with react-router
我在反应路线上遇到问题。 NoteList组件未呈现。 应用程序.js 我可以看到app.js文件中的div和h1 ,但看不到Notelist组件。 我怎么解决这个问题? ...
[英]Rendering of the timer stops while routing from one component to another
所以我做了一个简单的倒计时计时器,如果我路由到另一个组件,它会停止呈现更新的时间。 我使用了setInerval()更新倒计时时间,每当我路由到另一个组件时, setInterval()会继续运行但没有渲染发生并且倒计时计时器设置回其开始时间。 应用程序 倒数 定时器 这是应用程序的链接 - cod ...