react-paginate
react-paginate copied to clipboard
forcePage is not working
I'm updating offset and page by using state and the offset is updating and the list shows the right content. But the active page is not updating properly as I triggered using forcePage option. But it not works. Items are displaying for 1st page as offset updated. But the button active is in some other prev active number due to this
function PaginatedItems({ items, props, page, itemOffset, updateOffset }) {
const itemsPerPage = 10;
const endOffset = itemOffset + itemsPerPage;
const currentItems = items.slice(itemOffset, endOffset);
const pageCount = Math.ceil(items.length / itemsPerPage);
const handlePageClick = event => {
const newOffset = (event.selected * itemsPerPage) % items.length;
updateOffset(newOffset);
};
return (
<>
<LocationListItems
locations={currentItems}
showSidePanel={props.showSidePanel}
hideSidePanel={props.hideSidePanel}
scopes={props.scopes}
/>
<ReactPaginate
onPageChange={handlePageClick}
pageRangeDisplayed={5}
pageCount={pageCount}
forcePage={page}*
renderOnZeroPageCount={null}
/>
</>
);
}
Kindly help me to resolve this. thank in advance!
Try -
const itemsPerPage = 10;
const currentItems = items.slice( itemsPerPage * 10 -10, itemsPerPage * 10)