> For the complete documentation index, see [llms.txt](https://kagura.gitbook.io/kagura-nusa-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kagura.gitbook.io/kagura-nusa-en/single-component/nssesary-traits.md).

# Nssesary Traits

To create a component in Html, it is needed to implment some traits.

### Component

`Component` is a comon trait for a component. This trait defines types of `Props`,`Msg` and`Events` in a component.

```rust
pub trait Component: Sized {
    type Props;
    type Event;
    type Msg;
}
```

### Constructor

This trait implements a constructor for a component. This constructor will be used, when the coponent is mounted to Html.

You can use `props: Self::Props` to initialize a component. In most cases, props gives from a parent component.

```rust
pub trait Constructor: Component {
    fn constructor(_props: Self::Props) -> Self;
}
```

### Update

This trait implements some features. The common point in these features is that its are used to update a component.

In most cases, `update` will be used. `on_assemble` will be used when a component is mounted first time. `on_load` will be used when a compoent is mounted from the second time.

You can update your component in `on_load` by `props`.

`Cmd<Self>` is a command to `kagura`. This usages are descripts later.

```rust
pub trait Update: Component {
    fn on_assemble(self: Pin<&mut Self>) -> Cmd<Self> {
        Cmd::None
    }
    fn on_load(self: Pin<&mut Self>, _props: Self::Props) -> Cmd<Self> {
        Cmd::None
    }
    fn update(self: Pin<&mut Self>, _msg: Self::Msg) -> Cmd<Self> {
        Cmd::None
    }
}
```

### Render\<Html>

When you create a component to render Html, it is needed to implements `Render<Html>`.&#x20;

```rust
pub trait Render<T>: Component {
    type Children: Default;
    fn render(&self, children: Self::Children) -> T;
}
```

### HtmlComponent

All of implements in this trait are already implemented. This trait is needed to convert a component to a Html node.
