Why useQuery runs multiple times?

my first time of using react query and facing issue of running API request multiple times, I dont know what causes this issue
am I doing anything wrong?

export const sendAuth = async ({ token }: { token?: string }) => {
  return axiosInstace()
    .post("/adminTokenVerify", { token })
    .then((res) => res.data);
};

export const useAdminAuth = () => {
  const [clientId, setClientId] = useState<string>("");
  const [email, setEmail] = useState<string>("");
  const [auth, setAuth] = useState<AUTH_STAGES>(AUTH_STAGES.AUTHORIZED);

  const token = localStorage.getItem(TOKEN_STORAGE_KEY.TOKEN);

  const { data } = useQuery(
    ["auth"],
    () => sendAuth({ token: JSON.parse(token!) })
  );

  return { clientId, email, auth };
};
image.png
Was this page helpful?