例如,我希望在路径为/注册时呈现SignUp组件。我所做的:我认为我可以使用initialEntries给MemoryRouter一个初始路径(不成功),然后我想我可能可以在内部的测试中直接使用路由/重定向来设置路径,但这也不起作用。Specification:
Jest (一个带有创建-反应-应用程序)
我有一个<UserListComponent />,它输出一个<Contact />组件和由<Contacts />表示的联系人列表。问题是,在对<UserListComponent />的测试中,当我尝试挂载它时,test输出一个错误Invariant Violation: You should not use <Route> orwithRouter() outside a <Router>
<Contacts
我正在使用ReactiveR外层Dom v6启动一个新项目,我遇到了第一步的麻烦:为应用程序设置路由。不,唯一呈现的页面是DashboardPage,即使我试图导航到不存在的路由。到目前为止,这是我的代码:import { createRoot } from 'react-dom/client'
import { MemoryRouter as Router} from 'react-rout
在尝试部署我的网站时,我遇到以下错误: Warning: Failed context type: The context `router` is marked as required in `Switcha <Router> 通常,我很确定问题出在哪里--受影响节点的父节点中的某个地方缺少路由器。但是,在我的示例中,SignIn呈现如下所示: return (
<div className="signInContai