Created
November 30, 2020 20:50
-
-
Save beelarr/24a14db2e0797af93e4511141d968dd7 to your computer and use it in GitHub Desktop.
A simple JS pagination example.
This file contains 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
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