score:0

function GoogleAuth() {
  const [isSignedIn, changeSignInStatus] = useState(null);

  var auth;

  useEffect(() => {
    //load client:auth2 library and define a callback
    if (!isSignedIn) {
      window.gapi.load("client:auth2", () => {
        window.gapi.client
          .init({
            clientId: "*****************************",
            scope: "email",
          })
          .then(() => {
            auth = window.gapi.auth2.getAuthInstance();
            changeSignInStatus(auth.isSignedIn.get());
            auth.isSignedIn.listen(onAuthChange);
          });
      });
    }
  }, [isSignedIn]);
}

Related Query

More Query from same tag