Skip to content

Commit

Permalink
✨ usePagination
Browse files Browse the repository at this point in the history
  • Loading branch information
h-campos committed Apr 26, 2023
1 parent 9bdeeda commit 6052fa5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hooks/usePagination/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { usePaginationStore } from './usePagination'
14 changes: 14 additions & 0 deletions src/hooks/usePagination/usePagination.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//Librairies
import { create } from 'zustand'

type PaginationStore = {
currentPage: number
nextPage: () => void
previousPage: () => void
}

export const usePaginationStore = create<PaginationStore>((set) => ({
currentPage: 0,
nextPage: () => set((state) => ({ currentPage: state.currentPage + 1 })),
previousPage: () => set((state) => ({ currentPage: state.currentPage - 1 })),
}))

0 comments on commit 6052fa5

Please sign in to comment.