-
for instance use leptos::{prelude::*, html::div};
#[component]
pub fn Foo(children: ChildrenFn) -> impl IntoView {
let as_child = RwSignal::new(false);
let children = StoredValue::new(children);
let children = move || children.with_value(|children| children());
view! {
<Show
when=move || as_child.get()
fallback=move || div().child(children())
>
{children()}
</Show>
<button on:click=move |_| as_child.update(|as_child| *as_child = !*as_child)>swap</button>
}
} and when used like so #[component]
fn App() -> impl IntoView {
view! {
<Foo attr:data-foo="test">
<span>test</span>
</Foo>
}
} should (or at least what i expected) yield <span data-foo="test">test</span> or <div data-foo="test">
<span>test</span>
</div> could be unintended behavior or something that i'm missing, but regardless no attributes specified in the component's usage is emitted big thanks in advance ️🔥 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
looking back on a previous discussion (#2922 (reply in thread)) it looks like <Show> would need to be changed to require more type information from its fallback |
Beta Was this translation helpful? Give feedback.
-
well that's embarrassing, turns out i overthought it; this is solved with a simple match + Either |
Beta Was this translation helpful? Give feedback.
well that's embarrassing, turns out i overthought it; this is solved with a simple match + Either