Skip to content

Commit

Permalink
Mejor usar metodos para handleClick de paginacion
Browse files Browse the repository at this point in the history
  • Loading branch information
hendaniel committed Sep 7, 2020
1 parent 86a976d commit 9cf530b
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/components/Products/ProductsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ const ProductsList = () => {

const { next, prev, currentData } = usePagination(products, 16);

const onPrev = () => {
prev();
window.scrollTo(0, 0);
};
const onNext = () => {
next();
window.scrollTo(0, 0);
};

if (products.length > 0) {
return (
<>
Expand All @@ -26,22 +35,8 @@ const ProductsList = () => {
<div className="container-pagination">
<div className="pagination">
<ul>
<button
onClick={() => {
prev();
window.scrollTo(0, 0);
}}
>
Previous
</button>
<button
onClick={() => {
next();
window.scrollTo(0, 0);
}}
>
Next
</button>
<button onClick={onPrev}>Previous</button>
<button onClick={onNext}>Next</button>
</ul>
</div>
</div>
Expand Down

0 comments on commit 9cf530b

Please sign in to comment.