diff --git a/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx b/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx index 159eb2e5f..fef109ebb 100644 --- a/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx +++ b/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx @@ -18,7 +18,7 @@ function GoogleSignIn({ customButtons, socialSignOnIn, className }) { iconLeft={GoogleIcon} className={`${className}__Google`} onClick={() => - window.google.accounts.id.prompt((notification) => { + window?.google?.accounts?.id?.prompt((notification) => { if (notification.isSkippedMoment()) { // https://developers.google.com/identity/gsi/web/reference/js-reference // https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown diff --git a/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js b/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js index 4a5abb165..4bf7692ed 100644 --- a/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js +++ b/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js @@ -133,22 +133,21 @@ function useSocialSignIn( }, [Identity, config.facebookAppId, customButtons]); useEffect(() => { + let timeout; const checkIsLoggedIn = () => { - const timeout = setTimeout(() => { + timeout = setTimeout(() => { Identity.isLoggedIn().then((isLoggedIn) => { if (isLoggedIn) { window.location = validateURL(redirectURL); } }); }, 1500); - return () => clearTimeout(timeout) }; const setIdentityUpdated = () => { - const timeout = setTimeout(() => { + timeout = setTimeout(() => { setUpdateIdentities((prev) => !prev); }, 1500); - return () => clearTimeout(timeout) }; if (customButtons && isFBInitialized && !isFBEventSubscribed && window?.FB?.Event) { @@ -163,6 +162,7 @@ function useSocialSignIn( } }); } + return () => clearTimeout(timeout); }, [ isFBInitialized, isFBEventSubscribed, @@ -174,11 +174,6 @@ function useSocialSignIn( redirectURL, ]); - - - - - return { // if facebook and google setup with subs, // then they will have a truthy value here