utopia-ui/src/Components/Map/ItemView.tsx
Ulf Gebhardt e79471c71a
docs: group by category
Groups the docs by categories and assigns all exported Components a
category (except types).
2025-02-18 03:07:35 +01:00

21 lines
479 B
TypeScript

import { Children, cloneElement, isValidElement } from 'react'
import type { Item } from '#types/Item'
/**
* @category Map
*/
export const ItemView = ({ children, item }: { children?: React.ReactNode; item?: Item }) => {
return (
<div>
{children
? Children.toArray(children).map((child) =>
isValidElement<{ item: Item }>(child) ? cloneElement(child, { item }) : null,
)
: null}
</div>
)
}
ItemView.__TYPE = 'ItemView'