import type { ComponentClass, ElementType, ForwardRefExoticComponent, FunctionComponent, PropsWithoutRef, Ref, RefAttributes, } from 'react' import { forwardRef } from 'react' import { jsxs } from './jsxs' export function createComponent< R extends HTMLElement, T extends FunctionComponent

| ComponentClass

| ElementType, P extends {} >( type: T, useHook: (props: P) => any ): ForwardRefExoticComponent & RefAttributes> { const Component = forwardRef((props: P, ref: Ref) => { const { children, ...parsedProps } = useHook(props) return jsxs(type, { ref, ...parsedProps }, children) }) Component.displayName = (type as any).displayName return Component as any }