mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
16 lines
426 B
TypeScript
16 lines
426 B
TypeScript
import { useContext } from 'react'
|
|
|
|
import ItemContext from './TemplateItemContext'
|
|
|
|
import type { Item } from '#types/Item'
|
|
|
|
export function templateify<T extends { item?: Item }>(Component: React.ComponentType<T>) {
|
|
const TemplateComponent = (props: T) => {
|
|
const item = useContext(ItemContext)
|
|
|
|
return <Component {...props} item={item} />
|
|
}
|
|
|
|
return TemplateComponent as React.ComponentType<Omit<T, 'item'>>
|
|
}
|