**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>
Here i implemented require auth but it's not working
CodePudding user response:
The RequireAuth
component needs to be wrapped within a Route
as follows:
<Route
path="/manageproducts"
element={
<RequireAuth>
<ManageProduct/>
</RequireAuth>
}
/>;
This would give Routes
a child of Route
and resolve the error you are getting