Fix infinite loop on table load (#12474)

This was a tough one:
- we should avoid updating lazy findManyRecords function with
onCompleted callback, this is prone to infinite loops
This commit is contained in:
Charles Bochet
2025-06-05 19:37:23 +02:00
committed by GitHub
parent 39d3c6a218
commit 9598a4dda2
2 changed files with 4 additions and 16 deletions

View File

@ -94,8 +94,6 @@ export const useLazyFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
set(hasNextPageFamilyState(queryIdentifier), false);
set(cursorFamilyState(queryIdentifier), '');
onCompleted?.([]);
return {
data: null,
loading: false,
@ -124,7 +122,6 @@ export const useLazyFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
findManyRecords,
objectMetadataItem.namePlural,
queryIdentifier,
onCompleted,
],
);

View File

@ -58,8 +58,6 @@ export const RecordTableNoRecordGroupBodyEffect = () => {
lastShowPageRecordIdState,
);
const [hasInitialized, setHasInitialized] = useState(false);
const { scrollToPosition } = useScrollToPosition();
useEffect(() => {
@ -142,21 +140,14 @@ export const RecordTableNoRecordGroupBodyEffect = () => {
]);
useEffect(() => {
setIsRecordTableInitialLoading(false);
if (showAuthModal) {
setIsRecordTableInitialLoading(false);
return;
}
if (!hasInitialized) {
findManyRecords();
setHasInitialized(true);
}
}, [
findManyRecords,
hasInitialized,
setIsRecordTableInitialLoading,
showAuthModal,
]);
findManyRecords();
}, [findManyRecords, setIsRecordTableInitialLoading, showAuthModal]);
return <></>;
};