You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isLoading is typed as false when using fallbackData
Expected Behavior
According to https://swr.vercel.app/docs/advanced/understanding#fallback, when fallbackData is set it will still run the initial fetch, and sLoading will be true while that's happening. When checking the values for isLoading this is what happens. However the type doesn't match, meaning we currently need to disable linting checks or cast isLoading to a boolean.
Checking the type isLoading it will be reported as false rather that boolean. If you remove fallbackData the type will correctly be reported as boolean
Additional Context
SWR version: v2.2.4
The text was updated successfully, but these errors were encountered:
Bug report
Description / Observed Behavior
isLoading
is typed as false when usingfallbackData
Expected Behavior
According to https://swr.vercel.app/docs/advanced/understanding#fallback, when
fallbackData
is set it will still run the initial fetch, andsLoading
will be true while that's happening. When checking the values for isLoading this is what happens. However the type doesn't match, meaning we currently need to disable linting checks or cast isLoading to a boolean.Repro Steps / Code Example
const { data, isLoading } = useSWR('key', () => Promise.resolve([]), { fallbackData: [] });
Checking the type isLoading it will be reported as
false
rather thatboolean
. If you removefallbackData
the type will correctly be reported asboolean
Additional Context
SWR version: v2.2.4
The text was updated successfully, but these errors were encountered: