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:
@ -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,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@ -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 <></>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user