This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
yew::html

Trait BaseComponent

Source
pub trait BaseComponent: Sized + 'static {
    type Message: 'static;
    type Properties: Properties;

    // Required methods
    fn create(ctx: &Context<Self>) -> Self;
    fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool;
    fn changed(
        &mut self,
        ctx: &Context<Self>,
        _old_props: &Self::Properties,
    ) -> bool;
    fn view(&self, ctx: &Context<Self>) -> HtmlResult;
    fn rendered(&mut self, ctx: &Context<Self>, first_render: bool);
    fn destroy(&mut self, ctx: &Context<Self>);
    fn prepare_state(&self) -> Option<String>;
}
Expand description

The common base of both function components and struct components.

If you are taken here by doc links, you might be looking for Component or #[function_component].

We provide a blanket implementation of this trait for every member that implements Component.

§Warning

This trait may be subject to heavy changes between versions and is not intended for direct implementation.

You should used the Component trait or the #[function_component] macro to define your components.

Required Associated Types§

Source

type Message: 'static

The Component’s Message.

Source

type Properties: Properties

The Component’s Properties.

Required Methods§

Source

fn create(ctx: &Context<Self>) -> Self

Creates a component.

Source

fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool

Updates component’s internal state.

Source

fn changed( &mut self, ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool

React to changes of component properties.

Source

fn view(&self, ctx: &Context<Self>) -> HtmlResult

Returns a component layout to be rendered.

Source

fn rendered(&mut self, ctx: &Context<Self>, first_render: bool)

Notified after a layout is rendered.

Source

fn destroy(&mut self, ctx: &Context<Self>)

Notified before a component is destroyed.

Source

fn prepare_state(&self) -> Option<String>

Prepares the server-side state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl BaseComponent for Suspense
where Self: 'static,

Available on crate features csr or ssr only.
Source§

impl<T> BaseComponent for PhantomComponent<T>
where T: BaseComponent + 'static, Self: 'static,

Source§

impl<T> BaseComponent for T
where T: Sized + Component + 'static,