This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
yew::html

Type Alias ChildrenWithProps

source
pub type ChildrenWithProps<CHILD> = ChildrenRenderer<VChild<CHILD>>;
Expand description

A type used for accepting children elements in Component::Properties and accessing their props.

§Example

model.rs

In this example, the List component can wrap ListItem components.

html! {
  <List>
    <ListItem value="a" />
    <ListItem value="b" />
    <ListItem value="c" />
  </List>
}

list.rs

The List component must define a children property in order to wrap the list items. The children property can be used to filter, mutate, and render the items.

#[derive(Clone, Properties, PartialEq)]
struct ListProps {
    children: ChildrenWithProps<ListItem>,
}

impl Component for List {
        html!{{
            for ctx.props().children.iter().map(|mut item| {
                let mut props = Rc::make_mut(&mut item.props);
                props.value = format!("item-{}", props.value);
                item
            })
        }}
    }
}

Aliased Type§

struct ChildrenWithProps<CHILD> { /* private fields */ }