react-query version 3 Flashcards
What kind of state does react-query manage
Server state
What is client state
Information relevant to a browser/front-end application session
Examples of client state
Chosen theme or language
What is server state
Data stored remotely in database
Example of server state
List of blog posts or any other such data
Where does react-query fit in
It has a cache of server state data, and does a request for new data when required, by using fetch/axios or any other method of fetching server data.
What is the source of truth for react-query
It’s cache
When wil react-query fetch data again?
Depends on how it’s been configured declaritively, via the queryclient, or when a key is invalidated imperatively.
Example of react-query cache
{
key:’blogs’,
data:{}
}
Name react-query core features
1) loading/error states
2) pagination/infinite scroll
3) Prefetching
4) Mutations and Queries
5) De-duplication of requests
6) Retry on error
7) Callbacks
8) Browser devtools
9) caching of data
What are the key react-query items that must be set up?
The provider and the query client
What is the difference between isLoading and isFetching
isLoading - When true, indicates that the query is loading when it has no cached data.
isFetching - When true, indicates that the query is currently fetching, but might have data from an earlier request.
What is staleTime
How long data can be out of date for before a refetch may be executed.
What is default staleTime
0ms
What is cacheTime
The amount of time that the data may be cached by react-query, after the most recent useQuery for this key.