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(hasNextPageFamilyState(queryIdentifier), false);
|
||||||
set(cursorFamilyState(queryIdentifier), '');
|
set(cursorFamilyState(queryIdentifier), '');
|
||||||
|
|
||||||
onCompleted?.([]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: null,
|
data: null,
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -124,7 +122,6 @@ export const useLazyFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
|||||||
findManyRecords,
|
findManyRecords,
|
||||||
objectMetadataItem.namePlural,
|
objectMetadataItem.namePlural,
|
||||||
queryIdentifier,
|
queryIdentifier,
|
||||||
onCompleted,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -58,8 +58,6 @@ export const RecordTableNoRecordGroupBodyEffect = () => {
|
|||||||
lastShowPageRecordIdState,
|
lastShowPageRecordIdState,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [hasInitialized, setHasInitialized] = useState(false);
|
|
||||||
|
|
||||||
const { scrollToPosition } = useScrollToPosition();
|
const { scrollToPosition } = useScrollToPosition();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -142,21 +140,14 @@ export const RecordTableNoRecordGroupBodyEffect = () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setIsRecordTableInitialLoading(false);
|
||||||
|
|
||||||
if (showAuthModal) {
|
if (showAuthModal) {
|
||||||
setIsRecordTableInitialLoading(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasInitialized) {
|
findManyRecords();
|
||||||
findManyRecords();
|
}, [findManyRecords, setIsRecordTableInitialLoading, showAuthModal]);
|
||||||
setHasInitialized(true);
|
|
||||||
}
|
|
||||||
}, [
|
|
||||||
findManyRecords,
|
|
||||||
hasInitialized,
|
|
||||||
setIsRecordTableInitialLoading,
|
|
||||||
showAuthModal,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user