Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
7 replies
Codex

Question about useQuery

I have a query set up like follows
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
}
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?
Was this page helpful?