added privateRoute
This commit is contained in:
parent
23ac3f2b6a
commit
625e09deba
1 changed files with 10 additions and 0 deletions
10
real_estate/client/src/components/PrivateRoute.jsx
Normal file
10
real_estate/client/src/components/PrivateRoute.jsx
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { useSelector } from "react-redux"
|
||||||
|
import { Outlet, Navigate } from "react-router-dom"
|
||||||
|
|
||||||
|
const PrivateRoute = () => {
|
||||||
|
const {currentUser} = useSelector((state) => state.user)
|
||||||
|
return currentUser ? <Outlet/> : <Navigate to='/login' />
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
export default PrivateRoute
|
Loading…
Add table
Reference in a new issue