createEmptyPlaceholderPlugin
Create an empty/loading placeholder plugin
import {
createEmptyPlaceholderPlugin,
} from "@roku-sdk/flex-grid/empty-placeholder";createEmptyPlaceholderPlugin<T = unknown>(config: EmptyPlaceholderConfig<T>): InitGridPlugin<T>Description
Create an empty/loading placeholder plugin. Pass the returned object in FlexGridConfig.plugins.
Parameters
| Name | Type | Description |
|---|---|---|
config | EmptyPlaceholderConfig<T> |
Return values
Returns InitGridPlugin<T>.
Example
import { createEmptyPlaceholderPlugin } from "@roku-sdk/flex-grid/empty-placeholder";
createFlexGrid({
plugins: [
createEmptyPlaceholderPlugin({
renderEmptyPlaceholder: ({ width, height }) => (
<rectangle width={width()} height={height()} color="0x1A1A1AFF" />
)
})
],
poolBuffer: { default: 24, emptyPlaceholder: 8 }
});Types
EmptyPlaceholderConfig
Empty Placeholder Config configuration and callbacks.
| Name | Type | Description |
|---|---|---|
isEmpty? | (item: T | undefined, row: number, col: number) => boolean | Decides which cells are treated as unresolved. See below. |
renderEmptyPlaceholder | (ctx: EmptyPlaceholderContext) => Element | Render the placeholder for an unresolved cell. See below. |
templateId? | string | Pool template key for placeholder nodes. See below. |
EmptyPlaceholderConfig.isEmpty
Decides which cells are treated as unresolved. Defaults to item === undefined, which matches the grid's own "row is loading" state (store.rows[i] === undefined).
Note a loaded-but-empty row ([]) collapses to zero height and so has nowhere to draw — this plugin covers the loading state, not that one.
EmptyPlaceholderConfig.renderEmptyPlaceholder
Render the placeholder for an unresolved cell. Return any component output; a rectangle, a skeleton composition, a poster, whatever the app needs.
Receives reactive accessors: read them inside JSX props, createMemo, or createEffect, and never destructure the values at the top level. The nodes are pooled, so a slot is recycled to a different row/col as the grid scrolls; reading row() once would freeze every recycled slot on whichever row it first displayed.
EmptyPlaceholderConfig.templateId
Pool template key for placeholder nodes. Defaults to "emptyPlaceholder".
Warm it like any other template; poolBuffer: { emptyPlaceholder: 8 }. Must not collide with an id the app returns from getCellTemplateId, or real cells and placeholders would share pooled nodes.
EmptyPlaceholderContext
Reactive context handed to EmptyPlaceholderConfig.renderEmptyPlaceholder.
| Name | Type | Description |
|---|---|---|
col | Accessor<number> | Reactive accessor for the data column index this pooled slot currently shows. |
height | Accessor<number> | Reactive accessor for this cell's height in pixels. |
row | Accessor<number> | Reactive accessor for the data row index this pooled slot currently shows. |
width | Accessor<number> | Reactive accessor for this cell's width in pixels. |
Updated about 3 hours ago