Skip to content

Instantly share code, notes, and snippets.

@alperbayram
Last active June 5, 2022 21:55
Show Gist options
  • Save alperbayram/547b8a66bf4cdbb965c4f6b2548d92e9 to your computer and use it in GitHub Desktop.
Save alperbayram/547b8a66bf4cdbb965c4f6b2548d92e9 to your computer and use it in GitHub Desktop.
Protected Routes
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