-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
react-query-firebaseIssue is specific to React Query Firebase branchIssue is specific to React Query Firebase branch
Description
I have a wrapper component that redirects unauthenticated users and renders the children (layout in my case) if the user is logged in.
But sometimes it works and sometimes it wont load anything that it is wrapped around.
"use client"
import { useAuthUser } from "@react-query-firebase/auth";
import { redirect } from 'next/navigation';
import { auth } from "../firebase-config";
export function UserRedirectOnLoggedOut({children, href}) {
const user = useAuthUser(["user"], auth);
if (user.isLoading) {
return <div />;
}
if (user.data) {
return (
<>
{children}
</>
);
}
redirect(href);
}
Can anyone help me out ?
Metadata
Metadata
Assignees
Labels
react-query-firebaseIssue is specific to React Query Firebase branchIssue is specific to React Query Firebase branch
Type
Projects
Status
Opened