-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Bug report
I upgraded from 2.2.5 to 2.3.6.
I've tested older versions to determine this broke with 2.3.0
Description / Observed Behavior
For simplicity i'm describing the case where the backend returns an empty page.
with >= 2.3.0 the data returned from useSwrInfinite is [null]
. The custom fetcher is not invoked. Before the upgrade this used to return undefined
as an initial value.
The incorrect data crashes my app.
Expected Behavior
With 2.2.25 the data is: [{"totalCount":0,"data":[]}]
. This is returned by the backend webservice call. (data property is not data property of useSWRInfinite. )
Repro Steps / Code Example
interface ResponseProtocol {
data: Array<unknown>;
statusCode?: number;
};
const {
data, // This is incorrect with >=2.3.0
mutate,
setSize,
isValidating,
isLoading,
error: rawError
} =
useSWRInfinite<ResponseProtocol>(getKey, {
refreshInterval: pollingInterval,
onSuccess: undefined,
compare: dequal,// https://www.npmjs.com/package/dequal
fallbackData: undefined
});
Additional Context
SWR version.
2.3.0 to 2.3.6
Metadata
Metadata
Assignees
Labels
No labels