From d27638f6f619c61cc31e33ea042f578ac7f9a0e1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 09:19:51 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Performance:=20Fix=20missing=20depe?= =?UTF-8?q?ndencies=20and=20TDZ=20in=20useTokenGate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added missing dependencies 'session' and 'verify' to the auto-verify useEffect hook in useTokenGate. Moved the verify callback definition above the useEffect to avoid ReferenceError due to Temporal Dead Zone. Intentionally omitted 'isVerifying' from dependencies to prevent an infinite loop on verification failure. These changes ensure the hook correctly reacts to session changes and wallet reconnections, improving application reactivity and efficiency. Co-authored-by: Henry6262 <37511508+Henry6262@users.noreply.github.com> --- src/hooks/useTokenGate.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hooks/useTokenGate.ts b/src/hooks/useTokenGate.ts index 613be58..b6c2c95 100644 --- a/src/hooks/useTokenGate.ts +++ b/src/hooks/useTokenGate.ts @@ -84,13 +84,6 @@ export function useTokenGate(): TokenGateState { return () => clearInterval(interval); }, [session]); - // Auto-verify when wallet connects but no valid session - useEffect(() => { - if (connected && publicKey && !isSessionValid(session, publicKey) && !isVerifying) { - verify(); - } - }, [connected, publicKey]); - // Verify balance and create/update session const verify = useCallback(async (): Promise => { if (!connected || !publicKey) { @@ -126,6 +119,13 @@ export function useTokenGate(): TokenGateState { } }, [connected, publicKey, refetchBalance]); + // Auto-verify when wallet connects but no valid session + useEffect(() => { + if (connected && publicKey && !isSessionValid(session, publicKey) && !isVerifying) { + verify(); + } + }, [connected, publicKey, session, verify]); + // Clear session and require re-verification const clearSessionHandler = useCallback(() => { setSession(null);