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 andEvents in a component.
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.
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.
Render<Html>
When you create a component to render Html, it is needed to implements Render<Html>.
HtmlComponent
All of implements in this trait are already implemented. This trait is needed to convert a component to a Html node.
Last updated