I am trying to pass the params to the react query through the hook.
export const useUserInfo = (enabled, {token}) => {
return useQuery(
["users-info", token],
() => fetchUserInfo(token),
{
enabled: enabled,
},
);
};
const Auth = () => {
const { refetch } = useUserInfo(false); // calling this hook and getting refetch
const handleLoginPopup = async () => {
try {
const token = "abcd121212"
const { data: userInfo } = await refetch(true, {token:token }); // Here I want to pass a token
dispatch({ type: "SET_USER", payload: userInfo });
navigate("/");
location.reload();
} catch (error) {
console.error(error);
}
};
}
Here, But I am not able to pass it. as I am getting an error as token is undefined here even after defining it . also I tried giving a default value as well.
Can any one help me in passing the extra params to the react query hook.