What will we do?
We will use React Query/TanStack Query to cache the data fetched from API. The API that will be used for testing will be the Books API provided by FreeTestAPI.
Caching Data with React Query and Hooks
If you have integrated Apis in your React js website, then you know that whenever a page is refreshed the data is re-fetched every time whether you have used useEffect to fetch data on the component mount or used some custom functions to fetch data. This results in unnecessary requests and decreased performance. For that situation, caching is a very good option so in this article, we’ll see how to cache that data using React Query which is now known as TanStack Query.
Table of Content
- What will we do?
- What is React Query/TanStack Query?
- How does TanStack Query work?
- Conclusion
- FAQs
Contact Us