Skip to content

Instantly share code, notes, and snippets.

@oquirozm
Created November 9, 2019 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oquirozm/7a4e976d239d453706b16d1d737d1672 to your computer and use it in GitHub Desktop.
Save oquirozm/7a4e976d239d453706b16d1d737d1672 to your computer and use it in GitHub Desktop.
import { useState } from 'react';
function usePagination() {
const [page, setPage] = useState(1);
const nextPage = () => setPage(page + 1);
const prevPage = () => setPage(page - 1);
return { page, setters: { prevPage, nextPage } };
}
export default usePagination;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment