mirror of
https://github.com/leptos-rs/book.git
synced 2025-12-27 10:01:41 -05:00
fix: use .into_any() instead of .into_view() for type erasure (closes #210)
This commit is contained in:
@@ -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()
|
||||
}}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user