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

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

A wrapper component that monuts/unmounts a number of the given component based on the Vector<Props>.

Note that this takes a im_rc::Vector, not a std::vec::Vec.

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

For each item in the vector, a component is mounted with the item as props.

If the vector grows, more components are mounted. If the vector shrinks, some components are dismounted.

A note of caution: Component number i gets props number i. Shifting part of the Vector won’t shift the components’ states. This is like keying React components in a loop with the index.

Components loses all state when unmounted.

Use like this

cc_tree!(
    <vec_comps {(my_comp, vector![props1, props2, props3])} />
)

Each component is mounted/unmouned as its own Subtree.

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