The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
useEffect instead
Steven Tey1e515faf8301
diff --git a/apps/web/app/app.dub.co/(auth)/login/form.tsx b/apps/web/app/app.dub.co/(auth)/login/form.tsxindex be50a8e1b7..ea550c6328 100644--- a/apps/web/app/app.dub.co/(auth)/login/form.tsx+++ b/apps/web/app/app.dub.co/(auth)/login/form.tsx@@ -26,17 +26,26 @@ export default function LoginForm() {const { isMobile } = useMediaQuery();+ useEffect(() => {+ // when leave page, reset state+ return () => {+ setClickedGoogle(false);+ setClickedGithub(false);+ setClickedEmail(false);+ setClickedSSO(false);+ };+ }, []);+return (<><div className="flex space-x-2"><Buttonvariant="secondary"- onClick={async () => {+ onClick={() => {setClickedGoogle(true);- await signIn("google", {+ signIn("google", {...(next && next.length > 0 ? { callbackUrl: next } : {}),});- setClickedGoogle(false);}}loading={clickedGoogle}disabled={clickedEmail || clickedSSO}@@ -44,12 +53,11 @@ export default function LoginForm() {/><Buttonvariant="secondary"- onClick={async () => {+ onClick={() => {setClickedGithub(true);- await signIn("github", {+ signIn("github", {...(next && next.length > 0 ? { callbackUrl: next } : {}),});- setClickedGithub(false);}}loading={clickedGitub}disabled={clickedEmail || clickedSSO}diff --git a/apps/web/app/app.dub.co/(auth)/register/form.tsx b/apps/web/app/app.dub.co/(auth)/register/form.tsxindex 22e8103cf7..f637a2b605 100644--- a/apps/web/app/app.dub.co/(auth)/register/form.tsx+++ b/apps/web/app/app.dub.co/(auth)/register/form.tsx@@ -4,7 +4,7 @@ import { Button, Github, Google } from "@dub/ui";import { signIn } from "next-auth/react";import Link from "next/link";import { useSearchParams } from "next/navigation";-import { useState } from "react";+import { useEffect, useState } from "react";export default function RegisterForm() {const searchParams = useSearchParams();@@ -12,29 +12,35 @@ export default function RegisterForm() {const [clickedGoogle, setClickedGoogle] = useState(false);const [clickedGitub, setClickedGithub] = useState(false);+ useEffect(() => {+ // when leave page, reset state+ return () => {+ setClickedGoogle(false);+ setClickedGithub(false);+ };+ }, []);+return (<><Buttonvariant="secondary"text="Continue with Google"- onClick={async () => {+ onClick={() => {setClickedGoogle(true);- await signIn("google", {+ signIn("google", {...(next && next.length > 0 ? { callbackUrl: next } : {}),});- setClickedGoogle(false);}}loading={clickedGoogle}icon={<Google className="h-4 w-4" />}/><Buttontext="Continue with GitHub"- onClick={async () => {+ onClick={() => {setClickedGithub(true);- await signIn("github", {+ signIn("github", {...(next && next.length > 0 ? { callbackUrl: next } : {}),});- setClickedGithub(false);}}loading={clickedGitub}icon={<Github className="h-4 w-4" />}