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§
Sourcetype Properties: Properties
type Properties: Properties
The Component’s Properties.
Required Methods§
Sourcefn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool
Updates component’s internal state.
Sourcefn changed(
&mut self,
ctx: &Context<Self>,
_old_props: &Self::Properties,
) -> bool
fn changed( &mut self, ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool
React to changes of component properties.
Sourcefn view(&self, ctx: &Context<Self>) -> HtmlResult
fn view(&self, ctx: &Context<Self>) -> HtmlResult
Returns a component layout to be rendered.
Sourcefn rendered(&mut self, ctx: &Context<Self>, first_render: bool)
fn rendered(&mut self, ctx: &Context<Self>, first_render: bool)
Notified after a layout is rendered.
Sourcefn prepare_state(&self) -> Option<String>
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 Suspensewhere
Self: 'static,
Available on crate features csr
or ssr
only.
impl BaseComponent for Suspensewhere
Self: 'static,
csr
or ssr
only.