@zeix/ui-element
Version:
UIElement - a HTML-first library for reactive Web Components
49 lines (25 loc) • 980 B
Markdown
[**@zeix/ui-element**](../README.md)
***
[@zeix/ui-element](../globals.md) / component
# Function: component()
> **component**\<`P`\>(`name`, `init`, `setup`): `void`
Defined in: [src/component.ts:285](https://github.com/zeixcom/ui-element/blob/297c0e8e040b3880ad85a2bc873523a8086f09a3/src/component.ts#L285)
Define a component with its states and setup function (connectedCallback)
## Type Parameters
### P
`P` *extends* [`ComponentProps`](../type-aliases/ComponentProps.md)
## Parameters
### name
`string`
Name of the custom element
### init
\{ \[K in string \| number \| symbol\]: Initializer\<P\[K\], Component\<P\>\> \} = `...`
Signals of the component
### setup
(`host`, `select`) => [`Effect`](../type-aliases/Effect.md)\<`P`, [`Component`](../type-aliases/Component.md)\<`P`\>\>[]
Setup function to be called in connectedCallback(), may return cleanup function to be called in disconnectedCallback()
@returns: void
## Returns
`void`
## Since
0.12.0