-
-
- information relevant to the browser session
- ex.) user's chosen language or light/dark theme
-
- information stored on the server needed to render Components on multiple Clients
- ex.) blog post data from the database
-
-
- React Query cache sits between the client and the server
- So when API/Data queries are sent, it first checks is that data available in the React Query cache
-
-
Indicate when to update React Query cache with new data from server
-
imperatively: invalidate data and refetch
-
declaratively: configure how (ex. window focus) & when to trigger a re-fetch
Cache Example key: 'blog-posts' data: [ 1: { title: 'React Query', tagLine: 'What is this thing?' }, 2: { title: 'React Query Mutations', tagLine: 'Not just for ninja turtles' } ] staleTime: 30 seconds
-
-
-
- pre-fetch the data, put it in the cache and then when the user needs it, the data is immediately available