How To use useQuery with dependency array ?
Hello guys, I'm trying to convert this useEffect to useQuery. I have some issues with the dependency array. can some one help to slove this problem ?
useEffect(() => {
let isActive = true;
if (!loading) setLoading(true);
async function fetchData() {
const { data, error } = await supabase
.from("team_users")
.select(
team_id(
project:project_team_id_fkey(
id,
name,
is_archived,
description,
url,
status
),
name,
id
)
)
.match({ user_id: session.user.id });
// const { data, error } = await supabase.from('team').select(*)
if (error) {
console.log(error);
} else {
console.log(data);
if (isActive) {
console.log(data)
setHomeData([...data]);
}
}
}
fetchData().finally(() => {
setLoading(false);
console.log("Api Called");
});
return () => {
isActive = false;
};
}, [NewPCreated, projectAchieving, refetchHomeData]);1 Reply
metropolitan-bronze•3y ago