ListItem
What a List's renderItem receives for one row: the item, its position, and whether the row is on screen.
Utilização
Scroll a list in a test.
Este tipo é usado por List
// Scroll a list in a test.
import { List, Text } from 'kuito';
import { assert, render, screen, scroll, test } from 'kuito/tests';
const rows = Array.from({ length: 200 }, (_, index) => `Row ${index}`);
const Long = () => <List data={rows} renderItem={({ item }) => <Text height={44}>{item}</Text>} />;
test('rows far down bind once the list scrolls to them', async () => {
await render(<Long />);
assert.equal(screen.queryByText('Row 150'), null);
await scroll(screen.getByText('Row 0'), { y: 150 * 44 });
assert.ok(screen.getByText('Row 150'));
});Declaração do tipo
export interface ListItem<T> {
item: T;
/** The item's position, a signal like `For`'s index: it follows items before it as they come and go. */
index: ReadonlySignal<number>;
/** Whether the row is on screen, by `viewability`'s threshold. */
visible: ReadonlySignal<boolean>;
}Membros 3
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
item | T | Sim | — |
index | ReadonlySignal<number> | Sim | The item's position, a signal like For's index: it follows items before it as they come and go. |
visible | ReadonlySignal<boolean> | Sim | Whether the row is on screen, by viewability's threshold. |
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.