Fix infinite scroll on the poster list

This commit is contained in:
Grégoire Delattre 2020-04-03 19:07:31 +02:00
parent 817da07a2d
commit 56dbd65730

View File

@ -98,6 +98,7 @@ const Posters = ({
const [size, setSize] = useState(0);
const [postersPerRow, setPostersPerRow] = useState(0);
const [posterHeight, setPosterHeight] = useState(0);
const [initialLoading, setInitialLoading] = useState(true);
const loadMore = useCallback(() => {
if (size === elmts.size) {
@ -111,8 +112,11 @@ const Posters = ({
}, [size, elmts.size]);
useEffect(() => {
loadMore();
}, [elmts.size, loadMore]);
if (initialLoading) {
loadMore();
setInitialLoading(false);
}
}, [loadMore, initialLoading, setInitialLoading]);
const move = useCallback(
(event) => {