This is the code for pagination that needs to add dots if pages are more than 5. How it could be done.
const pages = _.range(1, pageCount + 1);
const pagination = (pageNo) => {
setcurrentPage(pageNo);
const startIndex = (pageNo - 1) * pageSize;
const paginatedItem = _(ItemList).slice(startIndex).take(pageSize).value()
setpaginatedList(paginatedItem)
}
<nav className="d-flex justify-content-center">
<ul className="pagination">
{
pages.map((page) => (
<li className={page === currentPage ? "page-item active" : "page-item "}>
<p className="page-link"
onClick={() => pagination(page)}
>{page}</p>
</li>
))
}
</ul>
</nav>
<nav className="d-flex justify-content-center">
<ul className="pagination">
{
pages.map((page) => (
<li className={page === currentPage ? "page-item active" : "page-item "}>
<p className="page-link"
onClick={() => pagination(page)}
>{page}{page > 5 && "."}</p>
</li>
))
}
</ul>
</nav>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.