Skip to content

Instantly share code, notes, and snippets.

@beelarr
Created November 30, 2020 20:50
Show Gist options
  • Save beelarr/24a14db2e0797af93e4511141d968dd7 to your computer and use it in GitHub Desktop.
Save beelarr/24a14db2e0797af93e4511141d968dd7 to your computer and use it in GitHub Desktop.
A simple JS pagination example.
export const pagination = ({data = [], pageSize = 5}) => {
const page = data.slice(0, pageSize)
const otherPages =
data.slice(pageSize).length > pageSize
? pagination(data.slice(pageSize))
: [data.slice(pageSize)]
return [page, ...otherPages]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment