How to force fresh data (no cache) from query #4666
-
Is there a way to tell a specific query call to bypass cache? I seen the docs on cache but a little confused how I could do it without having to worry about invalidating the cache first. Simply tell a query to get new fresh data from api. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
caching is performed on a time basis. Depending on the set |
Beta Was this translation helpful? Give feedback.
-
Can i you give an example code snippet? how can I remove caching for a API call. |
Beta Was this translation helpful? Give feedback.
caching is performed on a time basis. Depending on the set
staleTime
, react-query will fetch new data or only read from the cache. To "force" a refetch, you have to imperatively call a method that refetches, e.g.queryClient.invalidateQueries
orqueryClient.refetchQueries