Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): handle optional auth context in useCurrentUser

Richie McIlroya89b09cc47a3
diff --git a/apps/web/app/Layout/AuthContext.tsx b/apps/web/app/Layout/AuthContext.tsx
index d5dfe9741..da6dc6b6a 100644
--- a/apps/web/app/Layout/AuthContext.tsx
+++ b/apps/web/app/Layout/AuthContext.tsx
@@ -16,6 +16,7 @@ export type CurrentUser = {
const AuthContext = createContext<
{ user: Promise<CurrentUser | null> } | undefined
>(undefined);
+const anonymousUser = Promise.resolve(null);
export function AuthContextProvider({
children,
@@ -38,5 +39,6 @@ export function useAuthContext() {
}
export function useCurrentUser() {
- return use(useAuthContext().user);
+ const context = use(AuthContext);
+ return use(context?.user ?? anonymousUser);
}