From 43b13b992c0260d5540736d56b1b705669d3cc7a Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Sat, 28 Nov 2020 13:23:34 +0200 Subject: [PATCH] show 6 on page (infinite scroller) --- components/common/MyInfiniteScroller.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/common/MyInfiniteScroller.tsx b/components/common/MyInfiniteScroller.tsx index 4b20e0508..b5b5ec507 100644 --- a/components/common/MyInfiniteScroller.tsx +++ b/components/common/MyInfiniteScroller.tsx @@ -5,8 +5,10 @@ import { Flex } from "@chakra-ui/react"; import { ReactElement, ReactNodeArray, useState } from "react"; import InfiniteScroll from "react-infinite-scroller"; +const ON_PAGE = 6; + const MyInfiniteScroller: React.FC = ({ children }) => { - const [elementsToShow, setElementsToShow] = useState(12); + const [elementsToShow, setElementsToShow] = useState(ON_PAGE); if (!Array.isArray(children)) throw Error("children for MyInfiniteScroller is not an array"); @@ -14,7 +16,7 @@ const MyInfiniteScroller: React.FC = ({ children }) => { return ( setElementsToShow(page * 12)} + loadMore={(page) => setElementsToShow(page * ON_PAGE)} hasMore={elementsToShow < children.length} >