Skip to content

Commit

Permalink
add nextUri in dependency array (#1217)
Browse files Browse the repository at this point in the history
  • Loading branch information
kb019 authored Dec 2, 2024
1 parent fb69d2d commit f1bd0cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/framework/esm-react-utils/src/useOpenmrsFetchAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export function useServerFetchAll<T, R>(
options: UseServerFetchAllOptions<R> = {},
): UseServerInfiniteReturnObject<T, R> {
const response = useServerInfinite<T, R>(url, serverPaginationHandlers, options);
const { hasMore, error, data, loadMore, isLoading } = response;
const { hasMore, error, data, loadMore, isLoading, nextUri } = response;

useEffect(() => {
if (hasMore && !error) {
loadMore();
}
}, [hasMore, data]);
}, [hasMore, nextUri]);

if (options.partialData) {
return response;
Expand Down
5 changes: 5 additions & 0 deletions packages/framework/esm-react-utils/src/useOpenmrsInfinite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export interface UseServerInfiniteReturnObject<T, R> {
* from useSWRInfinite
*/
isLoading: boolean;
/**
* from useSWRInfinite
*/
nextUri: string | null;
}

/**
Expand Down Expand Up @@ -147,6 +151,7 @@ export function useServerInfinite<T, R>(
totalCount,
hasMore,
loadMore,
nextUri,
...rest,
};
}

0 comments on commit f1bd0cc

Please sign in to comment.