pagination bug fixed

This commit is contained in:
Sendou 2020-03-19 01:21:50 +02:00
parent ed563e302c
commit fd6fdf6b3d
2 changed files with 10 additions and 3 deletions

View File

@ -8,7 +8,11 @@ interface PaginationProps {
onChange: (page: number) => void
}
const Pagination: React.FC<PaginationProps> = ({ pageCount, onChange }) => {
const Pagination: React.FC<PaginationProps> = ({
pageCount,
onChange,
currentPage,
}) => {
return (
<ReactPaginate
previousLabel={<>&laquo;</>}
@ -18,7 +22,8 @@ const Pagination: React.FC<PaginationProps> = ({ pageCount, onChange }) => {
pageCount={pageCount}
marginPagesDisplayed={2}
pageRangeDisplayed={3}
onPageChange={({ selected }) => onChange(selected)}
onPageChange={({ selected }) => onChange(selected + 1)}
forcePage={currentPage - 1}
containerClassName="pagination"
pageClassName="page"
previousClassName="page"

View File

@ -98,6 +98,8 @@ const Top500BrowserPage: React.FC<RouteComponentProps> = () => {
const placements = data ? data.searchForPlacements.placements : []
console.log("forms.page", forms.page)
return (
<>
<Helmet>
@ -115,7 +117,7 @@ const Top500BrowserPage: React.FC<RouteComponentProps> = () => {
</Box>
</Flex>
</Box>
<Box mt="2em" mb="1em">
<Box mt="1em">
<Pagination
currentPage={forms.page ?? 1}
pageCount={data?.searchForPlacements.pageCount ?? 999}