parent
fac4b29c79
commit
d068099f93
2 changed files with 44 additions and 2 deletions
@ -0,0 +1,28 @@ |
||||
import React from "react"; |
||||
|
||||
const Pagination = ({ postsPerPage, totalPosts, paginate }) => { |
||||
const pageNumbers = []; |
||||
|
||||
for (let i = 1; i <= Math.ceil(totalPosts / postsPerPage); i++) { |
||||
pageNumbers.push(i); |
||||
} |
||||
|
||||
return ( |
||||
<div> |
||||
<ul className="flex gap-x-2 items-center mt-4"> |
||||
{pageNumbers.map((number) => ( |
||||
<li |
||||
key={number} |
||||
className="border border-blue-400 bg-blue-200 rounded-sm px-2 py-1" |
||||
> |
||||
<p onClick={() => paginate(number)} className=""> |
||||
{number} |
||||
</p> |
||||
</li> |
||||
))} |
||||
</ul> |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
export default Pagination; |
Loading…
Reference in new issue