From 09e5e631b6679f6e61ba320bfae55b3da140ac50 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain Date: Fri, 25 Nov 2022 13:06:34 +0530 Subject: [PATCH] fix: redirection from index page --- contexts/user.context.tsx | 2 +- package.json | 2 +- pages/index.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contexts/user.context.tsx b/contexts/user.context.tsx index c42be1110..55037af14 100644 --- a/contexts/user.context.tsx +++ b/contexts/user.context.tsx @@ -131,7 +131,7 @@ export const UserProvider = ({ children }: { children: ReactElement }) => { { const { user, isUserLoading, activeWorkspace, workspaces } = useUser(); - if (!isUserLoading && !user) router.push("/signin"); + useEffect(() => { + if (!isUserLoading && (!user || user === null)) router.push("/signin"); + }, [isUserLoading, user, router]); useEffect(() => { if (!activeWorkspace && workspaces?.length === 0) router.push("/invitations");