mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
fix(ui): ensure initial data fetch only happens once (#2486)
# What does this PR do? Bug: 1. go to responses chat logs in UI 2. go to chat completions logs page 3. observe that same data appears in the table twice This is because `fetchData` is called multiple times when multiple renders occur. ## Test Plan manual testing of above bug repro steps
This commit is contained in:
parent
9c8be89fb6
commit
7fa8f23555
1 changed files with 8 additions and 2 deletions
|
@ -56,6 +56,9 @@ export function usePagination<T>({
|
||||||
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,11 @@ export function usePagination<T>({
|
||||||
|
|
||||||
// Auto-load initial data on mount
|
// Auto-load initial data on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!hasFetchedInitialData.current) {
|
||||||
|
hasFetchedInitialData.current = true;
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}
|
||||||
|
}, [fetchData]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: state.data,
|
data: state.data,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue