In useSWR
, both isLoading
and isValidating
represent states of the data-fetching process, but they serve different purposes:
- Definition: Indicates the very first fetch for the given SWR key.
- State:
true
only when there is no cached data and the fetch is in progress. - Lifecycle:
- Active during the initial fetch when no data exists.
- Becomes
false
once data is fetched or available in the cache.