mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 02:53:30 +00:00
fix(ui): ensure initial data fetch only happens once
# What does this PR do? ## Test Plan
This commit is contained in:
parent
d3b60507d7
commit
8c87715da5
1 changed files with 9 additions and 2 deletions
|
@ -55,6 +55,9 @@ export function usePagination<T>({
|
||||||
// Use refs to avoid stale closures
|
// Use refs to avoid stale closures
|
||||||
const stateRef = useRef(state);
|
const stateRef = useRef(state);
|
||||||
stateRef.current = state;
|
stateRef.current = state;
|
||||||
|
|
||||||
|
// Track if initial data has been fetched
|
||||||
|
const hasFetchedInitialData = useRef(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches data from the API with cursor-based pagination
|
* Fetches data from the API with cursor-based pagination
|
||||||
|
@ -119,8 +122,12 @@ export function usePagination<T>({
|
||||||
|
|
||||||
// Auto-load initial data on mount
|
// Auto-load initial data on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchData();
|
if (!hasFetchedInitialData.current) {
|
||||||
}, []);
|
hasFetchedInitialData.current = true;
|
||||||
|
fetchData();
|
||||||
|
}
|
||||||
|
}, [fetchData]);
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: state.data,
|
data: state.data,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue