@cerberus-design/react
Version:
The Cerberus Design React component library.
29 lines (28 loc) • 876 B
text/typescript
import { JSX } from 'react';
export interface ForProps<T extends readonly unknown[], U extends JSX.Element> {
/**
* The array to iterate over.
*/
each: T | undefined | null | false;
/**
* The fallback to render when the array is empty.
*/
fallback?: JSX.Element;
/**
* The children to render for each item in the array.
*/
children: (item: T[number], index: number) => U;
}
/**
* The For component is used to iterate over an array and render a list of
* components or display a fallback when the array is empty.
* Inspired by the `<For>` component from SolidJS.
*
* @example
* ```tsx
* <For each={['a', 'b', 'c']}>
* {(item, index) => <div key={index}>{item}</div>}
* </For>
* ```
*/
export declare function For<T extends readonly unknown[], U extends JSX.Element>(props: ForProps<T, U>): JSX.Element | null;