Function consecuit::construction::subtrees::opt_comp[][src]

pub fn opt_comp<Ret, Props>(
    cc: ComponentBuilder,
    (func, props): (ComponentFunc<Ret, Props>, Option<Props>)
) -> impl ComponentReturn where
    Ret: ComponentReturn,
    Props: ComponentProps
Expand description

A wrapper component that monuts/unmounts the given component based on the Option<Props>.

Takes a tuple of (the component function, Option<its props>).

Component is mounted when props is Some(props). Component is unmouned when props is None.

Component loses all state when unmounted.

Use like this

cc_tree!(
    <opt_comp {(my_comp, Some(my_comp_props))} />
    <opt_comp {(other_comp, None)} />
)

Component is mounted/unmouned as its own Subtree.

The child component is wrapped in a <div style="display: contents">...</div>.