Skip to content

Commit

Permalink
(fix) - O3-3189 - fix useOpemrsInfinite hook to correctly take in URL…
Browse files Browse the repository at this point in the history
… object (#1146)
  • Loading branch information
chibongho authored Sep 8, 2024
1 parent 3f27fab commit 2c36c62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useServerFetchAll<T, R>(
if (hasMore && !error) {
loadMore();
}
});
}, [hasMore]);

if (options.partialData) {
return response;
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/esm-react-utils/src/useOpenmrsInfinite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export function useServerInfinite<T, R>(
const { getNextUrl, getTotalCount, getData } = serverPaginationHandlers;
const fetcher: (key: string) => Promise<FetchResponse<R>> = options.fetcher ?? openmrsFetch;
const getKey = useCallback(
(pageIndex: number, previousPageData: FetchResponse<R>) => {
(pageIndex: number, previousPageData: FetchResponse<R>): string | null => {
if (pageIndex == 0) {
return url;
return url?.toString() ?? null;
} else {
return serverPaginationHandlers.getNextUrl(previousPageData.data);
}
Expand Down

0 comments on commit 2c36c62

Please sign in to comment.