IfLoggedIn.tsx

 1import * as React from 'react';
 2
 3import { useCurrentIdentityQuery } from '../Identity/CurrentIdentity.generated';
 4
 5type Props = { children: () => React.ReactNode };
 6const IfLoggedIn = ({ children }: Props) => {
 7  const { loading, error, data } = useCurrentIdentityQuery();
 8
 9  if (error || loading || !data?.repository?.userIdentity) return null;
10
11  return <>{children()}</>;
12};
13
14export default IfLoggedIn;