pub struct Children<'a, G>where
G: GenericNode,{ /* private fields */ }
Expand description
A special property type to allow the component to accept children.
Add a field called children
of this type to your properties struct.
Example
#[derive(Prop)]
struct RowProps<'a, G: Html> {
width: i32,
children: Children<'a, G>,
}
#[component]
fn Row<'a, G: Html>(cx: Scope<'a>, props: RowProps<'a, G>) -> View<G> {
// Convert the `Children` into a `View<G>`.
let children = props.children.call(cx);
view! { cx,
div {
(children)
}
}
}
// Using `Row` somewhere else in your app:
view! { cx,
Row(width=10) {
p { "This is a child node." }
}
}
Implementations
sourceimpl<'a, G> Children<'a, G>where
G: GenericNode,
impl<'a, G> Children<'a, G>where
G: GenericNode,
sourcepub fn call(self, cx: BoundedScope<'_, 'a>) -> View<G>
pub fn call(self, cx: BoundedScope<'_, 'a>) -> View<G>
sourcepub fn new(
_cx: BoundedScope<'a, 'a>,
f: impl FnOnce(BoundedScope<'_, 'a>) -> View<G> + 'a
) -> Children<'a, G>
pub fn new(
_cx: BoundedScope<'a, 'a>,
f: impl FnOnce(BoundedScope<'_, 'a>) -> View<G> + 'a
) -> Children<'a, G>
Create a new Children
from a closure.
Trait Implementations
sourceimpl<'a, G> Debug for Children<'a, G>where
G: GenericNode,
impl<'a, G> Debug for Children<'a, G>where
G: GenericNode,
sourceimpl<'a, F, G> From<F> for Children<'a, G>where
G: GenericNode,
F: 'a + FnOnce(BoundedScope<'_, 'a>) -> View<G>,
impl<'a, F, G> From<F> for Children<'a, G>where
G: GenericNode,
F: 'a + FnOnce(BoundedScope<'_, 'a>) -> View<G>,
Auto Trait Implementations
impl<'a, G> !RefUnwindSafe for Children<'a, G>
impl<'a, G> !Send for Children<'a, G>
impl<'a, G> !Sync for Children<'a, G>
impl<'a, G> Unpin for Children<'a, G>
impl<'a, G> !UnwindSafe for Children<'a, G>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more