mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
18 lines
454 B
TypeScript
18 lines
454 B
TypeScript
import { Children, cloneElement, isValidElement } from 'react'
|
|
|
|
import type { Item } from '#types/Item'
|
|
|
|
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'
|