# Nssesary 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kagura.gitbook.io/kagura-nusa-en/single-component/nssesary-traits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
