I succeded to paginate my posts but couldn't add next and prev buttons and make them dynamically using this code snippet:
import React from 'react'
const Pagination = ({postsPerPage, totalPosts, paginate}) => {
console.log(totalPosts)
const PageNumbers = []
const int = Math.ceil(totalPosts / postsPerPage)
if (int === 1 ) return null
for (let i = 1; i<= int; i++) {
PageNumbers.push(i)
}
return (
<nav aria-label="Page navigation example">
<ul className="pagination">
{PageNumbers.map(number=> (
<li key={number} className="page-item">
<a onClick={ ()=> paginate(number)} href="!#" className="page-link">
{number}
</a>
</li>
))}
</ul>
</nav>
)
}
export default Pagination
please help to find way to include these buttons next and prev dynamically to my pagination who appears down. It's working great but needs next and prev
