@lesnoypudge/utils-react
Version:
lesnoypudge's utils-react
31 lines (30 loc) • 1.17 kB
TypeScript
import { RT } from '@lesnoypudge/types-utils-react/namespace';
export declare namespace Iterate {
type ChildrenArgsWithItems<_Item> = [
item: _Item,
index: number,
items: _Item[]
];
type ChildrenArgsWithCount = [
index: number
];
type GetKeyWithItems<_Item> = (item: _Item, index: number) => string | number;
type GetKeyWithCount = (index: number) => string | number;
type PropsWithItems<_Item> = (RT.PropsWithRequiredRenderFunction<ChildrenArgsWithItems<_Item>> & {
items: _Item[];
count?: never;
getKey: GetKeyWithItems<_Item>;
});
type PropsWithCount = (RT.PropsWithRequiredRenderFunction<ChildrenArgsWithCount> & {
items?: never;
count: number;
getKey: GetKeyWithCount;
});
type Props<_Item> = (PropsWithItems<_Item> | PropsWithCount);
}
/**
* Iterates over provided items or count and renders children as functions.
*
* Wraps children with React.Fragment with key returned by `getKey`.
*/
export declare const Iterate: <_Item>({ items, count, getKey, children, }: Iterate.Props<_Item>) => import("react/jsx-runtime").JSX.Element[];