Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeReact

useInfiniteRead

Reads an indexer list page by page, such as a name's subnames or an account's names. Signature, result and examples for useInfiniteRead.

Read hookstable
Since v1.0.0View source

Reads an indexer list page by page, such as a name's subnames or an account's names.

When to use

Use for "load more" lists and infinite scroll. A write touching the list's name or account starts it over once the indexer has caught up. Pass undefined options (or enabled: false) to wait, e.g. until a name is typed.

Signature

function useInfiniteRead<action extends PageAction>(action: action, options: Omit<ActionOptions<action>, "cursor"> | undefined, config: { /** * Load the list. Passing `undefined` options also disables it. * * @default true */ readonly enabled?: boolean | undefined; readonly client?: Ensforge.Client | undefined; } = {}): InfiniteReadResult<ActionValue<action>, ActionError<action>>

Examples

Subnames with
import { Actions } from "@ensforge/sdk"
import { useInfiniteRead } from "@ensforge/react"

function Subnames({ name }: { name: string }) {
  const { items, hasMore, loadMore } = useInfiniteRead(Actions.indexer.getSubnames, { name })
  return (
    <>
      {items.map((item) => <p key={item.name}>{item.name}</p>)}
      {hasMore && <button onClick={loadMore}>Load more</button>}
    </>
  )
}

See also

  • The hook types: ReadResult, WriteResult and ReadConfig.

Was this page helpful?