trying to fix protected route data fetch problem and only one more problem somewhere in the
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { useRouter } from "next/router";
|
||||
import toast from "react-hot-toast";
|
||||
import { useAuth } from "./authContext";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function ProtectedRoute({ children }) {
|
||||
const { currUser } = useAuth();
|
||||
|
||||
// figure out what content to render from here
|
||||
const router = useRouter();
|
||||
|
||||
// useEffect(() => {}, []);
|
||||
|
||||
if (!currUser) {
|
||||
console.log("not authenticated...routing from dashboard to teams home");
|
||||
toast.error("Not Authenticated");
|
||||
router.push("/teams/login");
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return <>{currUser && children}</>;
|
||||
}
|
||||
Reference in New Issue
Block a user