Skip to content

Instantly share code, notes, and snippets.

@danecando
Last active May 1, 2025 11:49
Show Gist options
  • Save danecando/57b03230768dcbfff7b47edf44f66f43 to your computer and use it in GitHub Desktop.
Save danecando/57b03230768dcbfff7b47edf44f66f43 to your computer and use it in GitHub Desktop.
import * as React from "react";
interface Props<T extends Promise<any>[]> {
promises: T;
children: (results: { [P in keyof T]: Awaited<T[P]> }) => React.ReactNode;
}
export function Awaiter<T extends Promise<any>[]>({ promises, children }: Props<T>) {
const results = React.use(Promise.all(promises));
return <>{children(results)}</>;
}
export function EmailNotVerified({ children }: EmailNotVerifiedProps) {
return (
<React.Suspense>
<Awaiter promises={[authClient.getAuthUser()]}>
{([user]) => {
if (!user || user?.emailVerified) {
return null;
}
return children;
}}
</Awaiter>
</React.Suspense>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment