Renaming loading to pending
The loading
status has caused some confusion. This is because most people associate it with data loading; secondly, if your query is disabled due to having the enabled
option as false
, it will show up as loading
. To avoid more confusion and have a clearer name, the loading
status has been renamed.
Here are the changes that have been applied:
- The
loading
status has been renamedpending
- The derived
isLoading
status has been renamedisPending
- A new derived
isLoading
flag has been added, which basically translates as theisPending &&
isFetching
expression - Considering that there was already a flag doing the same thing called
isInitialLoading
, theisInitialLoading
flag has been deprecated
Let us now review ComponentA
, which we saw in Chapter 4, and apply these changes:
const ComponentA = () => { const { data, error, isPending, isError, isFetching } = useQuery({ &...