From 439d9384236acd3cc0408d1c5c9942cfcd51e90e Mon Sep 17 00:00:00 2001 From: Aashish <83752052+120EE0692@users.noreply.github.com> Date: Tue, 10 Oct 2023 08:27:57 +0530 Subject: [PATCH] fix: gsi call after script load (#472) --- client/src/components/onboarding/stages/Welcome.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/components/onboarding/stages/Welcome.js b/client/src/components/onboarding/stages/Welcome.js index 32f7c140..78ebb6aa 100644 --- a/client/src/components/onboarding/stages/Welcome.js +++ b/client/src/components/onboarding/stages/Welcome.js @@ -56,7 +56,7 @@ function Welcome({ } } - function gis() { + function gsi() { google.accounts.id.initialize({ client_id: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, callback: handleCredentialResponse, @@ -70,7 +70,11 @@ function Welcome({ ); google.accounts.id.prompt(); } - gis(); + const script = document.createElement('script'); + script.src = 'https://accounts.google.com/gsi/client'; + script.strategy = 'beforeInteractive'; + script.onload = gsi; + document.head.appendChild(script); }, []); return (