useTableInfiniteScroll@astryxdesign/core v0.7.15 · useTableInfiniteScroll

Usage

Call useTableInfiniteScroll<T>({hasMore, isLoading, onLoadMore}) and pass the result to <Table plugins={{infiniteScroll: plugin}} />. Keep accumulated rows in your own state. onLoadMore must return a Promise<void> that settles when the batch work completes. A fulfilled request finishes after settlement and a subsequent committed isLoading=false; a true loading phase is not required. Visible short batches can automatically request again in a later task, so update hasMore when the source is exhausted. A resolved request that appends no rows must not incorrectly claim endless more data. Throws, rejections and invalid non-Promise results pause automatic loading; the manual Button can retry once controlled loading is false. The hook does not render product errors or cancel transport. For a new dataset, key and remount the component owning both the hook and its Table, not only the Table child; prevent stale responses from committing caller data yourself. Children mode and unsupported row models do not load and emit a deduplicated development warning. Body modifiers must declare compatible rowModel: flat. Observation uses the Table scroll area while the Table windows its rows, and the browser viewport otherwise, with zero look-ahead and no ancestor discovery. Without IntersectionObserver, the same manual command works.

ts
import {useTableInfiniteScroll} from '@astryxdesign/core/Table'

Parameters

ParamTypeDescription
hasMorerequired
boolean

Whether the source can provide another batch. False removes loading chrome and observation. Only a focused removed command hands focus to the shared Table viewport, without scrolling.

isLoadingrequired
boolean

Caller-controlled loading. Blocks requests while true. The outstanding request latch also keeps the Button busy through Promise settlement and the next false commit.

onLoadMorerequired
() => Promise<void>

Fetch and append the next batch, returning its completion Promise. Rows, cursors, errors and stale-response suppression stay caller-owned. Callback identity changes do not reset pending work or failure pause.

Examples

Common configurations, variations, and states.
useTableInfiniteScroll - Load More Products
Open in Playground

A Table appends product batches automatically or through its Load more command. The caller owns the rows, loading state and Promise-returning request. The command disappears when all products are loaded.

Use with shadcn

Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.

This install URL expires with the draft preview.
bash
npx shadcn@4.19.0 add https://astryx-7mrla3zsr-fbopensource.vercel.app/shadcn/hooks/use-table-infinite-scroll.json