Trait virtual_view::Component
[−]
[src]
pub trait Component: 'static + Any { fn render(
&self,
instance: &Instance,
props: &Props,
children: &Children
) -> View; fn name(&self) -> &'static str { ... } fn initial_state(&self, _props: &Props) -> Props { ... } fn context(&self, _props: &Props) -> Props { ... } fn inherit_context(&self, context: Props, _parent_context: &Props) -> Props { ... } fn will_mount(&self, _instance: &Instance) { ... } fn will_unmount(&self, _instance: &Instance) { ... } fn will_update(&self, _instance: &Instance) { ... } fn receive_props(
&self,
_instance: &Instance,
_next_state: &Props,
_next_props: &Props,
_next_children: &Children
) { ... } fn should_update(
&self,
_prev_state: &Props,
_prev_props: &Props,
_prev_children: &Children,
_next_state: &Props,
_next_props: &Props,
_next_children: &Children
) -> bool { ... } }
Required Methods
Provided Methods
fn name(&self) -> &'static str
fn initial_state(&self, _props: &Props) -> Props
return the inital state of the component
fn context(&self, _props: &Props) -> Props
return the inital context of the component, gets passed to children via inherit_context
fn inherit_context(&self, context: Props, _parent_context: &Props) -> Props
filter the passed context of the component
fn will_mount(&self, _instance: &Instance)
called before mount
fn will_unmount(&self, _instance: &Instance)
called before unmount
fn will_update(&self, _instance: &Instance)
called before update
fn receive_props(
&self,
_instance: &Instance,
_next_state: &Props,
_next_props: &Props,
_next_children: &Children
)
&self,
_instance: &Instance,
_next_state: &Props,
_next_props: &Props,
_next_children: &Children
)
called when component receives new state, props, or children
fn should_update(
&self,
_prev_state: &Props,
_prev_props: &Props,
_prev_children: &Children,
_next_state: &Props,
_next_props: &Props,
_next_children: &Children
) -> bool
&self,
_prev_state: &Props,
_prev_props: &Props,
_prev_children: &Children,
_next_state: &Props,
_next_props: &Props,
_next_children: &Children
) -> bool
if component needs update return true, defaults to true