logout trigger twice

I’m using react hooks and following the tutorial from https://auth0.com/docs/quickstart/spa/react/01-login

But my app doesn’t need the generic login/logout, it’s more like a check-in app with authorization and creates account handled by auth0. So in the following code, I logged out the user as soon as it’s login. The bug is that logout() function is triggered twice, and I couldn’t figure out what is the issue.

import React, { useEffect } from "react";
import { useAuth0 } from "../react-auth0-spa";

const LoginButton = ({ writeToDb }) => {
  const {
    isAuthenticated,
    loginWithRedirect,
    logout,
    loading,
    user
  } = useAuth0();

  useEffect(() => {
    // our user doesn't need to logout
    // so we are calling logout whenever they login
    if (isAuthenticated && !loading && user) {
      alert(`email: ${user.email} name: ${user.name}`); //trigged twiced
      writeToDb(user.name, user.email, user.picture); //async function add profile to database
      logout();
    }
  }, [isAuthenticated, loading, addNewAgent, logout, user]);

  return <button onClick={() => loginWithRedirect({})}>Check in</button>;
};

export default LoginButton;

Also logout() doesn’t get triggered every time, it’s happening intermittently. I’m using Chrome v78.0.3904.70, and the bug is not reproduced in my friend’s laptop