useQueryのreturns
data: TData|undefined
fetchしてきたもの
isPreviousData: boolean
keepPreviousDataを有効にしている時に、前のデータが出続けている間はtrueになる
status
idle if the query is idle. This only happens if a query is initialized with enabled: false and no initial data is available.
loading
cacheにdataがない時のfetch時にtrue
error
success if the query has received a response with no errors and is ready to display its data. The corresponding data property on the query is the data received from the successful fetch or if the query's enabled property is set to false and has not been fetched yet data is the first initialData supplied to the query on initialization.
isIdle/isLoading/isSuccess/isError
statusに対応
isFetching
cacheの有無に関わらず
dataUpdatedAt: number
The timestamp for when the query most recently returned the status as "success".
errors
isLoadingError: boolean
Will be true if the query failed while fetching for the first time.
isRefetchError: boolean
Will be true if the query failed while refetching.
error: null | TError
Defaults to null
The error object for the query, if an error was thrown.
errorUpdatedAt: number
The timestamp for when the query most recently returned the status as "error".
refetchs
isRefetching: boolean
Is true whenever a background refetch is in-flight, which does not include initial loading
Is the same as isFetching && !isLoading
refetch: (options: { throwOnError: boolean, cancelRefetch: boolean }) => Promise<UseQueryResult>
A function to manually refetch the query.
If the query errors, the error will only be logged. If you want an error to be thrown, pass the throwOnError: true option
If cancelRefetch is true, then the current request will be cancelled before a new request is made
retrys
failureCount: number
The failure count for the query.
Incremented every time the query fails.
Reset to 0 when the query succeeds.
isStale: boolean
Will be true if the data in the cache is invalidated or if the data is older than the given staleTime.
isPlaceholderData: boolean
Will be true if the data shown is the placeholder data.
isFetched: boolean
Will be true if the query has been fetched.
isFetchedAfterMount: boolean
Will be true if the query has been fetched after the component mounted.
This property can be used to not show any previously cached data.
remove: () => void
A function to remove the query from the cache.