Skip to content

Commit ddbe9d4

Browse files
committed
Fix useInfinite
1 parent 2276e05 commit ddbe9d4

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swr-models",
3-
"version": "1.0.14",
3+
"version": "1.0.15",
44
"description": "SWR toolkit for abstracting API data models as React state objects.",
55
"keywords": [
66
"swr",

src/SWRModelEndpoint.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,17 @@ export class SWRModelEndpoint<T extends object> {
105105

106106
public useInfinite<R extends object = T>(config?: SWRModelEndpointConfigOverride) {
107107
const c = this._configMerge(config);
108-
return clientUseSWRInfinite<R>((index, previousPageData) => {
109-
if (previousPageData && !c.pagination?.hasMore(previousPageData)) return null;
110-
const params = {
111-
...c.params,
112-
...(c.pagination ? c.pagination.getParams(index, previousPageData) : {}),
113-
};
114-
return this.endpoint({ ...c, params });
115-
});
108+
return clientUseSWRInfinite<R>(
109+
(index, previousPageData) => {
110+
if (previousPageData && !c.pagination?.hasMore(previousPageData)) return null;
111+
const params = {
112+
...c.params,
113+
...(c.pagination ? c.pagination.getParams(index, previousPageData) : {}),
114+
};
115+
return this.endpoint({ ...c, params });
116+
},
117+
getJson,
118+
this._configMerge(config).swrConfig,
119+
);
116120
}
117121
}

0 commit comments

Comments
 (0)