Created
December 10, 2024 06:57
-
-
Save iamashiqur/993dfc8d5d76cc0c415d60287424b9a7 to your computer and use it in GitHub Desktop.
Pagination hook for mange pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState } from 'react' | |
| const usePagination = (initialPage: number = 1, initialLimit: number = 10) => { | |
| const [currentPage, setCurrentPage] = useState<number>(initialPage) | |
| const [pageLimit, setPageLimit] = useState<number>(initialLimit) | |
| const handlePageChange = (page: number) => { | |
| setCurrentPage(page) | |
| } | |
| const handlePageLimitChange = (limit: number) => { | |
| setPageLimit(limit) | |
| } | |
| return { | |
| currentPage, | |
| pageLimit, | |
| handlePageChange, | |
| handlePageLimitChange | |
| } | |
| } | |
| export default usePagination |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment