DEV Community

Joseph
Joseph

Posted on

Pagination using AWS AppSync

Step 1:
Create three states:

  1. Contain an array of tokens.
  2. Contain the current Page number
  3. A state maintaining our fetched data

state creation

Step 2:
Initiate the function to retrieve data from the graphql sever passing your tokens, here we use the useEffect and useCallback hook to manage the call function:

step 2 function creation

Step 3:
Create the next and previous buttons. Add the onClick event handler; this takes care of incrementing the page number or decrementing it.

Button Creation - Step 3

Top comments (0)