fix: setting set_pending now that <Transition/> body doesn't re-render (#1193)

This commit is contained in:
Greg Johnston 2023-06-15 20:09:22 -04:00 committed by GitHub
parent 23594a43ea
commit 77439b5db5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,9 @@
use leptos_dom::{Fragment, IntoView, View};
use leptos_macro::component;
use leptos_reactive::{use_context, Scope, SignalSetter, SuspenseContext};
use leptos_reactive::{
create_isomorphic_effect, use_context, Scope, SignalGet, SignalSetter,
SuspenseContext,
};
use std::{
cell::{Cell, RefCell},
rc::Rc,
@ -97,9 +100,6 @@ where
is_first_run(&first_run, &suspense_context);
first_run.set(is_first_run);
if let Some(set_pending) = &set_pending {
set_pending.set(true);
}
if let Some(prev_children) = &*prev_child.borrow() {
if is_first_run {
fallback().into_view(cx)
@ -132,9 +132,12 @@ where
}
child_runs.set(child_runs.get() + 1);
if let Some(set_pending) = &set_pending {
set_pending.set(false);
}
let pending = suspense_context.pending_resources;
create_isomorphic_effect(cx, move |_| {
if let Some(set_pending) = set_pending {
set_pending.set(pending.get() > 0)
}
});
frag
}))
.build(),