Skip to content

Commit

Permalink
fix: show first set of records
Browse files Browse the repository at this point in the history
  • Loading branch information
SH0PK33P3R committed Oct 7, 2020
1 parent 06b69bb commit bfde0fd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/dataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
const displayError = showError === 'built-in';
const [page, setPage] = useState(0);
const takeNum = parseInt(take, 10);
const initialRender = useRef(true);
const [skip, setSkip] = useState(0);
const autoLoadTakeAmountNum = parseInt(autoLoadTakeAmount, 10);
const [rowsPerPage, setRowsPerPage] = useState(takeNum);
const [search, setSearch] = useState('');
Expand Down Expand Up @@ -117,8 +119,6 @@
}, {});
};

const [skip, setSkip] = useState(0);

const searchFilter = searchProperty
? searchPropertyArray.reduceRight(
(acc, property, index) =>
Expand Down Expand Up @@ -367,7 +367,10 @@
useEffect(() => {
if (autoLoadOnScroll && !isDev) {
const increaseSkipAmount = () => {
setSkip(prev => prev + autoLoadTakeAmountNum);
if (!initialRender.current) {
setSkip(prev => prev + autoLoadTakeAmountNum);
}
initialRender.current = false;
};
const fetchNextSet = () => {
fetchingNextSet.current = true;
Expand Down Expand Up @@ -404,7 +407,7 @@
window.addEventListener('scroll', scrollEvent);
}
}
}, [totalCount, results]);
}, [results]);

return (
<div className={classes.root}>
Expand Down

0 comments on commit bfde0fd

Please sign in to comment.