fix - prevented double load

This commit is contained in:
Jan Prochazka
2020-04-14 19:39:22 +02:00
parent 113016c25c
commit cc4eb133a7

View File

@@ -214,19 +214,19 @@ export default function DataGridCore(props) {
const handleLoadRowCount = async () => { const handleLoadRowCount = async () => {
const rowCount = await loadRowCount(props); const rowCount = await loadRowCount(props);
setLoadProps({ setLoadProps((oldLoadProps) => ({
...loadProps, ...oldLoadProps,
allRowCount: rowCount, allRowCount: rowCount,
}); }));
}; };
const loadNextData = async () => { const loadNextData = async () => {
if (isLoading) return; if (isLoading) return;
setLoadProps({ setLoadProps((oldLoadProps) => ({
...loadProps, ...oldLoadProps,
isLoading: true, isLoading: true,
allRowCount: null, allRowCount: null,
}); }));
const loadStart = new Date().getTime(); const loadStart = new Date().getTime();
loadedTimeRef.current = loadStart; loadedTimeRef.current = loadStart;
@@ -246,11 +246,11 @@ export default function DataGridCore(props) {
loadedTime, loadedTime,
isLoadedAll: nextRows.length === 0, isLoadedAll: nextRows.length === 0,
}; };
setLoadProps({ setLoadProps((oldLoadProps) => ({
...loadProps, ...oldLoadProps,
isLoading: false, isLoading: false,
...loadedInfo, ...loadedInfo,
}); }));
}; };
// const data = useFetch({ // const data = useFetch({