diff --git a/packages/framework/esm-react-utils/src/useOpenmrsFetchAll.ts b/packages/framework/esm-react-utils/src/useOpenmrsFetchAll.ts index 6ff01277d..581a2c346 100644 --- a/packages/framework/esm-react-utils/src/useOpenmrsFetchAll.ts +++ b/packages/framework/esm-react-utils/src/useOpenmrsFetchAll.ts @@ -56,7 +56,7 @@ export function useServerFetchAll( if (hasMore && !error) { loadMore(); } - }); + }, [hasMore]); if (options.partialData) { return response; diff --git a/packages/framework/esm-react-utils/src/useOpenmrsInfinite.ts b/packages/framework/esm-react-utils/src/useOpenmrsInfinite.ts index ed8047870..fd68ad9d9 100644 --- a/packages/framework/esm-react-utils/src/useOpenmrsInfinite.ts +++ b/packages/framework/esm-react-utils/src/useOpenmrsInfinite.ts @@ -112,9 +112,9 @@ export function useServerInfinite( const { getNextUrl, getTotalCount, getData } = serverPaginationHandlers; const fetcher: (key: string) => Promise> = options.fetcher ?? openmrsFetch; const getKey = useCallback( - (pageIndex: number, previousPageData: FetchResponse) => { + (pageIndex: number, previousPageData: FetchResponse): string | null => { if (pageIndex == 0) { - return url; + return url?.toString() ?? null; } else { return serverPaginationHandlers.getNextUrl(previousPageData.data); }