Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(fix) O3-3189 - Fix useOpemrsInfinite hook to correctly take in URL #1146

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading