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>) -> Result<VNode, RenderError>;
    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>) -> Result<VNode, RenderError>

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.

Implementations on Foreign Types§

Source§

impl BaseComponent for Global
where Global: 'static,

Source§

type Message = ()

Source§

type Properties = GlobalProps

Source§

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

Source§

fn update( &mut self, _ctx: &Context<Global>, _msg: <Global as BaseComponent>::Message, ) -> bool

Source§

fn changed( &mut self, _ctx: &Context<Global>, _old_props: &<Global as BaseComponent>::Properties, ) -> bool

Source§

fn view(&self, ctx: &Context<Global>) -> Result<VNode, RenderError>

Source§

fn rendered(&mut self, _ctx: &Context<Global>, _first_render: bool)

Source§

fn destroy(&mut self, _ctx: &Context<Global>)

Source§

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

Source§

impl BaseComponent for ManagerProvider
where ManagerProvider: 'static,

Source§

impl BaseComponent for BrowserRouter
where BrowserRouter: 'static,

Source§

impl BaseComponent for HashRouter
where HashRouter: 'static,

Source§

impl BaseComponent for Router
where Router: 'static,

Source§

type Message = ()

Source§

type Properties = RouterProps

Source§

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

Source§

fn update( &mut self, _ctx: &Context<Router>, _msg: <Router as BaseComponent>::Message, ) -> bool

Source§

fn changed( &mut self, _ctx: &Context<Router>, _old_props: &<Router as BaseComponent>::Properties, ) -> bool

Source§

fn view(&self, ctx: &Context<Router>) -> Result<VNode, RenderError>

Source§

fn rendered(&mut self, _ctx: &Context<Router>, _first_render: bool)

Source§

fn destroy(&mut self, _ctx: &Context<Router>)

Source§

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

Source§

impl<R> BaseComponent for Redirect<R>
where R: Routable + 'static, Redirect<R>: 'static,

Source§

type Message = ()

Source§

type Properties = RedirectProps<R>

Source§

fn create(ctx: &Context<Redirect<R>>) -> Redirect<R>

Source§

fn update( &mut self, _ctx: &Context<Redirect<R>>, _msg: <Redirect<R> as BaseComponent>::Message, ) -> bool

Source§

fn changed( &mut self, _ctx: &Context<Redirect<R>>, _old_props: &<Redirect<R> as BaseComponent>::Properties, ) -> bool

Source§

fn view(&self, ctx: &Context<Redirect<R>>) -> Result<VNode, RenderError>

Source§

fn rendered(&mut self, _ctx: &Context<Redirect<R>>, _first_render: bool)

Source§

fn destroy(&mut self, _ctx: &Context<Redirect<R>>)

Source§

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

Source§

impl<R> BaseComponent for Switch<R>
where R: Routable + 'static, Switch<R>: 'static,

Source§

type Message = ()

Source§

type Properties = SwitchProps<R>

Source§

fn create(ctx: &Context<Switch<R>>) -> Switch<R>

Source§

fn update( &mut self, _ctx: &Context<Switch<R>>, _msg: <Switch<R> as BaseComponent>::Message, ) -> bool

Source§

fn changed( &mut self, _ctx: &Context<Switch<R>>, _old_props: &<Switch<R> as BaseComponent>::Properties, ) -> bool

Source§

fn view(&self, ctx: &Context<Switch<R>>) -> Result<VNode, RenderError>

Source§

fn rendered(&mut self, _ctx: &Context<Switch<R>>, _first_render: bool)

Source§

fn destroy(&mut self, _ctx: &Context<Switch<R>>)

Source§

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

Source§

impl<R, Q, S> BaseComponent for Link<R, Q, S>
where R: Routable + 'static, Q: Clone + PartialEq + Serialize + 'static, S: Clone + PartialEq + 'static, Link<R, Q, S>: 'static,

Source§

type Message = ()

Source§

type Properties = LinkProps<R, Q, S>

Source§

fn create(ctx: &Context<Link<R, Q, S>>) -> Link<R, Q, S>

Source§

fn update( &mut self, _ctx: &Context<Link<R, Q, S>>, _msg: <Link<R, Q, S> as BaseComponent>::Message, ) -> bool

Source§

fn changed( &mut self, _ctx: &Context<Link<R, Q, S>>, _old_props: &<Link<R, Q, S> as BaseComponent>::Properties, ) -> bool

Source§

fn view(&self, ctx: &Context<Link<R, Q, S>>) -> Result<VNode, RenderError>

Source§

fn rendered(&mut self, _ctx: &Context<Link<R, Q, S>>, _first_render: bool)

Source§

fn destroy(&mut self, _ctx: &Context<Link<R, Q, S>>)

Source§

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

Implementors§

Source§

impl BaseComponent for Head
where Self: 'static,

Source§

impl BaseComponent for Image
where Self: 'static,

Source§

impl BaseComponent for BaseRouter
where Self: 'static,

Source§

impl BaseComponent for NextRouter
where Self: 'static,

Source§

impl BaseComponent for next_rs::router::Switch
where Self: 'static,

Source§

impl BaseComponent for Accordion
where Accordion: 'static,

Source§

impl BaseComponent for AccordionButton
where AccordionButton: 'static,

Source§

impl BaseComponent for AccordionItem
where AccordionItem: 'static,

Source§

impl BaseComponent for Alert
where Alert: 'static,

Source§

impl BaseComponent for I18nProvider
where I18nProvider: 'static,

Source§

impl BaseComponent for CustomInput
where CustomInput: 'static,

Source§

impl BaseComponent for Navbar
where Navbar: 'static,

Source§

impl BaseComponent for Sidebar
where Sidebar: 'static,

Source§

impl BaseComponent for Suspense
where Suspense: 'static,

Source§

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

Source§

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