runtime.js:7 Uncaught Error: [RequireAuth] 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 的子代并解决你得到的错误