Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

error handling for login loading state (#46)

PickleNik76198adde7c4
diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsx
index 5442aa6c..49c2b577 100644
--- a/src/components/ui/navigation.tsx
+++ b/src/components/ui/navigation.tsx
@@ -36,8 +36,12 @@ export function Navigation() {
// NOTE: 1. loading == true -> 2. signIn() -> 3. session status == 'loading' (loading == false)
const handleSignIn = async () => {
- setLoading(true);
- await signIn('github');
+ try {
+ setLoading(true);
+ await signIn('github');
+ } catch {
+ setLoading(false);
+ }
};
const handleSignOut = async () => {
await signOut({ redirect: false });
@@ -153,7 +157,6 @@ export function Navigation() {
</DropdownMenuContent>
</DropdownMenu>
) : (
-
<Button
disabled={loading || status === 'loading'}
onClick={() => void handleSignIn()}