8000 fix(loading): Prevent isLoading from being true with fallbackData by Conqxeror · Pull Request #4140 · vercel/swr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(loading): Prevent isLoading from being true with fallbackData #4140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export type {
Middleware,
Arguments,
State,
ScopedMutator
ScopedMutator,
FetcherResponse
} from '../_internal'
6 changes: 3 additions & 3 deletions src/index/use-swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const useSWRHandler = <Data = any, Error = any>(

return {
isValidating: true,
isLoading: true,
isLoading: isUndefined(fallback),
...snapshot
}
}
Expand Down Expand Up @@ -278,8 +278,8 @@ export const useSWRHandler = <Data = any, Error = any>(

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
Expand Down
0