From 542e706328cc161ae4f52d4e3aba2cc09bd2bed8 Mon Sep 17 00:00:00 2001 From: navaneeth Date: Wed, 19 May 2021 12:05:29 +0530 Subject: [PATCH] Pagination component --- frontend/src/_components/Pagination.jsx | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 frontend/src/_components/Pagination.jsx diff --git a/frontend/src/_components/Pagination.jsx b/frontend/src/_components/Pagination.jsx new file mode 100644 index 0000000000..d19e6c86d7 --- /dev/null +++ b/frontend/src/_components/Pagination.jsx @@ -0,0 +1,39 @@ +import React, { useState, useEffect } from 'react'; + +export const Pagination = function Pagination({ + currentPage, count, totalPages, pageChanged +}) { + + function renderPageItem(i) { + return
  • gotoPage(i + 1)} className={`page-item ${currentPage === i + 1 ? 'active' : ''}`}>{i + 1}
  • + } + + function gotoPage(page) { + pageChanged(page) + } + + function gotoNextPage() { + gotoPage(currentPage + 1); + } + + function gotoPreviousPage() { + gotoPage(currentPage - 1); + } + + return (
    +

    Showing 1 to 8 of {count} entries

    + +
    ) +}