Compare commits

...

3 Commits
4271 ... 2693

Author SHA1 Message Date
Greg Johnston
ab69750c01 fmt 2024-07-29 08:37:47 -04:00
Greg Johnston
b90fe273d5 remove unused import 2024-07-29 08:28:36 -04:00
Greg Johnston
5f0fab9f63 fix: untrack children in Portal to avoid re-triggering it accidentally 2024-07-24 12:23:07 -04:00

View File

@@ -2,6 +2,11 @@ use crate::ChildrenFn;
use cfg_if::cfg_if;
use leptos_dom::IntoView;
use leptos_macro::component;
#[cfg(all(
target_arch = "wasm32",
any(feature = "hydrate", feature = "csr")
))]
use leptos_reactive::untrack;
/// Renders components somewhere else in the DOM.
///
@@ -36,6 +41,7 @@ pub fn Portal(
.unwrap_or_else(|| document().body().expect("body to exist").unchecked_into());
create_effect(move |_| {
leptos::logging::log!("inside Portal effect");
let tag = if is_svg { "g" } else { "div" };
let container = document()
@@ -53,7 +59,8 @@ pub fn Portal(
container.clone()
};
let _ = render_root.append_child(&children().into_view().get_mountable_node());
let children = untrack(|| children().into_view().get_mountable_node());
let _ = render_root.append_child(&children);
let _ = mount.append_child(&container);