Pagination

Large amounts of collectibles can be returned during querying, this section will help you manage the results to provide better UX to your users.

By default, the Assets Query will return 10 results.

Throughout the API we use Relay compliant pagination.

Page Information

This means we allow the following properties in pageInfo:

  • endCursor - The cursor of the last item returned

  • nextPage - The cursor for the start of the next page (This is the same as endCursor)

  • startCursor - The cursor of the first element retrieved

  • hasNextPage - If there are more pages of data

  • hasPreviousPage - If there is a previous page of data (Not supported)

In Query Arguments

When running a paginated query the following properties in the query arguments are available:

  • after - The cursor to start from. Typically this would be the endCursor from a previous query

  • first - The amount of items that you are requesting to be returned

Usage

import React from 'react'
import { useAccount } from 'wagmi'
import { ChainAddress } from '@fv-asset-registry/common'
import { useAssets } from '@futureverse/asset-register-react'
import { useFuturePassAccountAddress } from '@futureverse/react'

// React component to render all collectibles owned by a FuturePass user logged in.
export const AssetList = () => {
  const {
    assets
  } = useAssets(
    {
      first: 1000,
      after: "NA=="
    }
  )
  if (!assets) {
    return null
  }

  return (
    <div>
      {assets.map((asset) => <Asset key={asset.id} asset={asset} />)}
    </div>
  )

Last updated

Feedback

Docs

© 2023 -> ♾️