mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
show 6 on page (infinite scroller)
This commit is contained in:
@@ -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 (
|
||||
<InfiniteScroll
|
||||
pageStart={1}
|
||||
loadMore={(page) => setElementsToShow(page * 12)}
|
||||
loadMore={(page) => setElementsToShow(page * ON_PAGE)}
|
||||
hasMore={elementsToShow < children.length}
|
||||
>
|
||||
<Flex flexWrap="wrap" justifyContent="center" mt={4}>
|
||||
|
||||
Reference in New Issue
Block a user