import type { Dict } from "../../utils" export interface ForProps { /** * The array to iterate over */ each: T[] | readonly T[] | undefined /** * The fallback content to render when the array is empty */ fallback?: React.ReactNode | undefined /** * The render function to render each item in the array */ children: (item: Exclude, index: number) => React.ReactNode } export function For( props: ForProps, ): React.ReactNode { const { each, fallback, children } = props if (each?.length === 0) { return fallback || null } return each?.map(children as any) }