Caching in Frontend with React Query
Using stale time
const appActivityQuery = useQuery({
queryKey: ["appActivity", startDate, endDate],
queryFn: async () => {
const appActivityService = new AppActivityService(localDB);
const res = await appActivityService.getAllWithAllDocs({
startDate,
endDate,
});
return res;
},
staleTime: 60 * 1000,
});