diff --git a/llama_stack/ui/hooks/usePagination.ts b/llama_stack/ui/hooks/usePagination.ts index 135754a77..55a8d4ac8 100644 --- a/llama_stack/ui/hooks/usePagination.ts +++ b/llama_stack/ui/hooks/usePagination.ts @@ -56,6 +56,9 @@ export function usePagination({ const stateRef = useRef(state); stateRef.current = state; + // Track if initial data has been fetched + const hasFetchedInitialData = useRef(false); + /** * Fetches data from the API with cursor-based pagination */ @@ -119,8 +122,11 @@ export function usePagination({ // Auto-load initial data on mount useEffect(() => { - fetchData(); - }, []); + if (!hasFetchedInitialData.current) { + hasFetchedInitialData.current = true; + fetchData(); + } + }, [fetchData]); return { data: state.data,