JokcyJ
tRPC4y ago
5 replies
Jokcy

Cache not working for `useQuery`

I have a query like this:
const { data: article, isFetching } = api.public.getArticle.useQuery({
        id: targetId,
    });

which
targetId
is a dynamic value. When I change
targetId
from a to b then switch back from b to a, the
useQuery
hook still send a new request for
a
instead of using cache. Any idea how to make the cache work?
Was this page helpful?