fix: use .into_any() instead of .into_view() for type erasure (closes #210)

This commit is contained in:
Greg Johnston
2025-06-10 21:10:09 -04:00
parent 21b5b53f08
commit e055fa68e4
2 changed files with 6 additions and 6 deletions

View File

@@ -9,8 +9,8 @@ let once = Resource::new(move || count.get(), |count| async move { load_a(count)
view! {
<h1>"My Data"</h1>
{move || match once.get() {
None => view! { <p>"Loading..."</p> }.into_view(),
Some(data) => view! { <ShowData data/> }.into_view()
None => view! { <p>"Loading..."</p> }.into_any(),
Some(data) => view! { <ShowData data/> }.into_any()
}}
}
```
@@ -29,8 +29,8 @@ view! {
(Some(a), Some(b)) => view! {
<ShowA a/>
<ShowA b/>
}.into_view(),
_ => view! { <p>"Loading..."</p> }.into_view()
}.into_any(),
_ => view! { <p>"Loading..."</p> }.into_any()
}}
}
```

View File

@@ -357,8 +357,8 @@ fn App() -> impl IntoView {
<h2>"Converting between Types"</h2>
// e. Note: if branches return different types,
// you can convert between them with
// `.into_any()` (for different HTML element types)
// or `.into_view()` (for all view types)
// `.into_any()` or using the `Either` enums
// (`Either`, `EitherOf3`, `EitherOf4`, etc.)
{move || match is_odd() {
true if value.get() == 1 => {
// <pre> returns HtmlElement<Pre>