[英]Uncaught Error: [RouteWrapper] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
[英]runtime.js:7 Uncaught Error: [RequireAuth] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
**react route****I wanted to make a route that's secure but it's not working.**
<Routes>
<Route path='/' element={<Home></Home>}></Route>
<Route path='/home' element={<Home></Home>}></Route>
<Route path='/register' element={<Register></Register>}></Route>
<Route path='/login' element={<Login></Login>}></Route>
<RequireAuth>
<Route path='/manageproducts' element={<ManageProduct></ManageProduct>}></Route>
</RequireAuth>
</Routes>
</div>
在这里我实现了 require auth 但它不起作用
RequireAuth
组件需要包装在Route
中,如下所示:
<Route
path="/manageproducts"
element={
<RequireAuth>
<ManageProduct/>
</RequireAuth>
}
/>;
这将使Routes
成为Route
的子级并解决您遇到的错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.