Skip to content

Commit 46f6ded

Browse files
authored
fix: transition fallback (closes leptos-rs#562) (leptos-rs#563)
1 parent e9c4b49 commit 46f6ded

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

leptos/src/transition.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ where
7575
E: IntoView,
7676
{
7777
let prev_children = std::rc::Rc::new(RefCell::new(None::<Vec<View>>));
78+
79+
#[cfg(not(feature = "hydrate"))]
80+
let first_run = std::cell::Cell::new(true);
81+
82+
// in hydration mode, "first" run is on the server
83+
#[cfg(feature = "hydrate")]
84+
let first_run = std::cell::Cell::new(false);
85+
7886
crate::Suspense(
7987
cx,
8088
crate::SuspenseProps::builder()
@@ -93,7 +101,12 @@ where
93101
})
94102
.children(Box::new(move |cx| {
95103
let frag = children(cx);
96-
*prev_children.borrow_mut() = Some(frag.nodes.clone());
104+
105+
if !first_run.get() {
106+
*prev_children.borrow_mut() = Some(frag.nodes.clone());
107+
}
108+
first_run.set(false);
109+
97110
if let Some(set_pending) = &set_pending {
98111
set_pending.set(false);
99112
}

0 commit comments

Comments
 (0)