Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useGoogleLogin rerenders my component twice #354

Open
dominx99 opened this issue Jun 30, 2024 · 0 comments
Open

useGoogleLogin rerenders my component twice #354

dominx99 opened this issue Jun 30, 2024 · 0 comments

Comments

@dominx99
Copy link

dominx99 commented Jun 30, 2024

I encountered odd behavior regarding the useGoogleLogin hook because only having it in my component makes it render twice.

I got a simple example:

import { Button } from "@mui/joy";
import { useGoogleLogin } from "@react-oauth/google";

export const GoogleRegisterButton = () => {
  console.log('render GoogleRegisterButton');

  const registerWithGoogle = useGoogleLogin({
    scope: 'openid email profile',
    flow: 'auth-code',
    onSuccess: res => console.log(res.code),
  });

  return (
    <Button
      onClick={registerWithGoogle}
    >
      Register with google
    </Button>
  )
}

In the console render GoogleRegisterButton appears twice.

Do you know if that is necessary for this hook? when I want to call my backend service onSuccess there are two API calls.

Without this hook, there is only one message: render GoogleRegisterButton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant