You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<Suspense> doesn't fall back to its fallback, and <Transition> doesn't call set_pending, if a resource is reloading, rather than loading for the first time.
Leptos Dependencies
0.7.0-rc1
To Reproduce
use gloo_timers::future::TimeoutFuture;use leptos::prelude::*;asyncfnimportant_api_call(id:usize) -> String{TimeoutFuture::new(1_000).await;match id {0 => "Alice",1 => "Bob",2 => "Carol",
_ => "User not found",}.to_string()}#[component]fnApp() -> implIntoView{let(tab, set_tab) = signal(0);let(pending, set_pending) = signal(false);// this will reload every time `tab` changeslet user_data = LocalResource::new(move || important_api_call(tab.get()));view!{
<div class="buttons">
<button
on:click=move |_| set_tab.set(0)
class:selected=move || tab.get() == 0
>
"Tab A"
</button>
<button
on:click=move |_| set_tab.set(1)
class:selected=move || tab.get() == 1
>
"Tab B"
</button>
<button
on:click=move |_| set_tab.set(2)
class:selected=move || tab.get() == 2
>
"Tab C"
</button>
</div>
<p>
{move || if pending.get(){"Hang on..."} else {"Ready."}}
</p>
<Transition// the fallback will show initially// on subsequent reloads, the current child will// continue showing
fallback=move || view! { <p>"Loading initial data..."</p> }// this will be set to `true` whenever the transition is ongoing
set_pending
>
<p>
{move || user_data.read().as_deref().map(ToString::to_string)}
</p>
</Transition>
<Suspense
fallback=move || view! { <p>"Loading data..."</p> }
>
<p>
{move || user_data.read().as_deref().map(ToString::to_string)}
</p>
</Suspense>
}}fnmain(){
leptos::mount::mount_to_body(App)}
The text was updated successfully, but these errors were encountered:
Describe the bug
<Suspense>
doesn't fall back to itsfallback
, and<Transition>
doesn't callset_pending
, if a resource is reloading, rather than loading for the first time.Leptos Dependencies
0.7.0-rc1
To Reproduce
The text was updated successfully, but these errors were encountered: