diff --git a/src/index/index.ts b/src/index/index.ts index 2ae26b143..559a5e418 100644 --- a/src/index/index.ts +++ b/src/index/index.ts @@ -32,5 +32,6 @@ export type { Middleware, Arguments, State, - ScopedMutator + ScopedMutator, + FetcherResponse } from '../_internal' diff --git a/src/index/use-swr.ts b/src/index/use-swr.ts index 21c42a9c2..b660a054f 100644 --- a/src/index/use-swr.ts +++ b/src/index/use-swr.ts @@ -195,7 +195,7 @@ export const useSWRHandler = ( return { isValidating: true, - isLoading: true, + isLoading: isUndefined(fallback), ...snapshot } } @@ -278,8 +278,8 @@ export const useSWRHandler = ( const returnedData = keepPreviousData ? isUndefined(cachedData) - // checking undefined to avoid null being fallback as well - ? isUndefined(laggyDataRef.current) + ? // checking undefined to avoid null being fallback as well + isUndefined(laggyDataRef.current) ? data : laggyDataRef.current : cachedData