Last active
June 5, 2022 21:55
-
-
Save alperbayram/547b8a66bf4cdbb965c4f6b2548d92e9 to your computer and use it in GitHub Desktop.
Protected Routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Navigate, Outlet } from "react-router-dom"; | |
import { useAuth } from "../Context/AuthContex"; | |
const ProtectedRoutes = () => { | |
const { loggedIn } = useAuth(); | |
return loggedIn ? <Outlet /> : <Navigate to="/" />; | |
}; | |
export default ProtectedRoutes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment