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,