"use client"; import React, { useEffect, useState } from "react"; import ReactPaginate from "react-paginate"; import { MdKeyboardArrowRight, MdKeyboardArrowLeft } from "react-icons/md"; import { twMerge } from "tailwind-merge"; // Example items, to simulate fetching from another resources. const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; export default function Pagination({ itemsPerPage, Page, countPage, length, }: { itemsPerPage?: any; Page?: any; countPage?: any; length?: any; }) { // Here we use item offsets; we could also use page offsets // following the API or data you're working with. const [itemOffset, setItemOffset] = useState(0); // Simulate fetching items from another resources. // (This could be items from props; or items loaded in a local state // from an API endpoint with useEffect and useState) const endOffset = itemOffset + itemsPerPage; // console.log(`Loading items from ${itemOffset} to ${endOffset}`); const currentItems = items.slice(itemOffset, endOffset); const pageCount = Math.ceil(items.length / itemsPerPage); // Invoke when user click to request another page. const handlePageClick = (event: any) => { const newOffset = (event.selected * itemsPerPage) % items.length; console.log( `User requested page number ${event.selected}, which is offset ${newOffset}` ); setItemOffset(newOffset); // console.log(event.selected); console.log(event); Page(event.selected); }; console.log(countPage); // console.log(pageCount, "1111"); return ( <> {/* */} console.log(e)} nextLabel={} onPageChange={handlePageClick} pageRangeDisplayed={3} pageCount={Math.ceil(countPage / 5)} previousLabel={} pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md" className={twMerge( " flex flex-wrap gap-3 text-sm md:text-base w-full bottom-0 rounded-md p-1 bg-white/30 backdrop-blur-lg justify-center text-blue mt-5" )} activeClassName=" bg-blue text-blue shadow-md shadow-main" activeLinkClassName=" text-white w-full p-1 h-full" previousLinkClassName=" w-10 h-10 grid place-content-center rounded-lg text-sm shadow-md" nextLinkClassName=" w-10 h-10 grid place-content-center rounded-lg text-sm shadow-md" /> ); }