Skip to content

API Reference / @gtkx/react / index / createElementComponent

Variable: createElementComponent ​

const createElementComponent: <P>(typeName, cls?) => (props) => ReactNode

Defined in: components/element.d.ts:16

Creates a JSX component for a GType, including custom types created with registerClass. Generated JSX uses this factory to route element-valued props into named child slots, which bare intrinsic elements cannot do.

Supply the props type as the type argument. It cannot be inferred from the GType name; the default unknown accepts no attributes.

Type Parameters ​

P ​

P = unknown

Parameters ​

typeName ​

string

GType name, such as GtkButton or a custom registerClass type name.

cls? ​

unknown

Wrapper class to retain with its registration during tree shaking. Rendering uses typeName for lookup.

Returns ​

A component accepting the specified props.

(props) => ReactNode