React-query: Add Option to disable caching

Created on 8 Jan 2020  路  1Comment  路  Source: tannerlinsley/react-query

One issue I've had is that when writing tests, it's easy to run into problems caused by react-query's caching. It would be good to have an option to disable caching wholesale.

Most helpful comment

As stated in the docs you can play with cacheTime option

If and when a query is no longer being used, it becomes inactive and by default is cached in the background for 5 minutes. This time can be configured using the cacheTime option at both the global and query-level.

By setting cacheTime to 0 in the options, you can disable caching in a specific query but by setting this to the react-query's provider, you can disable caching for every query

>All comments

As stated in the docs you can play with cacheTime option

If and when a query is no longer being used, it becomes inactive and by default is cached in the background for 5 minutes. This time can be configured using the cacheTime option at both the global and query-level.

By setting cacheTime to 0 in the options, you can disable caching in a specific query but by setting this to the react-query's provider, you can disable caching for every query

Was this page helpful?
0 / 5 - 0 ratings