mirror of
https://github.com/leptos-rs/leptos
synced 2024-09-20 22:41:59 +00:00
docs: add new Children
types to macro docs (#454)
This commit is contained in:
parent
fec4ff4381
commit
2be4e8d959
2 changed files with 8 additions and 2 deletions
|
@ -172,3 +172,7 @@ pub type Children = Box<dyn FnOnce(Scope) -> Fragment>;
|
|||
/// A type for the `children` property on components that can be called
|
||||
/// more than once.
|
||||
pub type ChildrenFn = Box<dyn Fn(Scope) -> Fragment>;
|
||||
|
||||
/// A type for the `children` property on components that can be called
|
||||
/// more than once, but may mutate the children.
|
||||
pub type ChildrenFnMut = Box<dyn FnMut(Scope) -> Fragment>;
|
||||
|
|
|
@ -457,12 +457,14 @@ pub fn view(tokens: TokenStream) -> TokenStream {
|
|||
/// ```
|
||||
///
|
||||
/// 5. You can access the children passed into the component with the `children` property, which takes
|
||||
/// an argument of the form `Box<dyn FnOnce(Scope) -> Fragment>`.
|
||||
/// an argument of the type `Children`. This is an alias for `Box<dyn FnOnce(Scope) -> Fragment>`.
|
||||
/// If you need `children` to be a `Fn` or `FnMut`, you can use the `ChildrenFn` or `ChildrenFnMut`
|
||||
/// type aliases.
|
||||
///
|
||||
/// ```
|
||||
/// # use leptos::*;
|
||||
/// #[component]
|
||||
/// fn ComponentWithChildren(cx: Scope, children: Box<dyn FnOnce(Scope) -> Fragment>) -> impl IntoView {
|
||||
/// fn ComponentWithChildren(cx: Scope, children: Children) -> impl IntoView {
|
||||
/// view! {
|
||||
/// cx,
|
||||
/// <ul>
|
||||
|
|
Loading…
Reference in a new issue