Question about useQuery

I have a query set up like follows
const findMembershipQuery = api.manageMembership.searchMembership.useQuery(
{
accesses: accesses.join(","),
timeAccess,
},
{ enabled: false }
);
const findMembershipQuery = api.manageMembership.searchMembership.useQuery(
{
accesses: accesses.join(","),
timeAccess,
},
{ enabled: false }
);
and I want to refetch this data whenever accesses or timeAccess changes so I used a useEffect, but the problem is if I don't use
if (!findMembershipQuery.isFetched) {
// Code here
}
if (!findMembershipQuery.isFetched) {
// Code here
}
inside the useEffect it infinitely calls itself but this prevents it from grabbing the same information more than once even if the previousData is no longer the same. anyone know of a better way to do this?
5 Replies
Codex
CodexOP16mo ago
I managed to fix it with a workaround but I would still like to hear about a different solution because I don't think mine is ideal thankyou
Styly
Styly16mo ago
Look at Theo's recreating twitter video
Codex
CodexOP16mo ago
Could you send me the link please? I looked for it but I only found 2 videos on Twitter from him and neither are recreating it Thankyou in advance
__izilla__
__izilla__16mo ago
Theo - t3․gg
YouTube
T3 Stack Tutorial - FROM 0 TO PROD FOR $0 (Next.js, tRPC, TypeScrip...
I've never worked this hard on a video before. I really hope y'all can benefit from this 🙏 GITHUB REPO https://github.com/t3dotgg/chirp DEPLOYED APP https://xn--uo8h.t3.gg/ GET A JACKET IF YOU'RE COOL LIKE THAT https://shop.t3.gg/ ALL MY VIDEOS ARE POSTED EARLY ON PATREON https://www.patreon.com/t3dotgg Everything else (Twitch, Twitter, Discor...
Styly
Styly16mo ago
Yep
Want results from more Discord servers?
Add your server