fixes `DynChild` scope handling, but with...consequences
This commit is contained in:
parent
64e056ffa9
commit
6eb379a8c6
|
@ -47,7 +47,7 @@ where
|
|||
// Run children so that they render and execute resources
|
||||
let children = children(cx);
|
||||
|
||||
move || {
|
||||
move |cx| {
|
||||
match errors.with(Errors::is_empty) {
|
||||
true => children.clone().into_view(cx),
|
||||
false => view! { cx,
|
||||
|
|
|
@ -46,7 +46,7 @@ where
|
|||
{
|
||||
let memoized_when = create_memo(cx, move |_| when());
|
||||
|
||||
move || match memoized_when.get() {
|
||||
move |cx| match memoized_when.get() {
|
||||
true => children(cx).into_view(cx),
|
||||
false => fallback(cx).into_view(cx),
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ where
|
|||
let child = DynChild::new({
|
||||
#[cfg(not(any(feature = "csr", feature = "hydrate")))]
|
||||
let current_id = current_id.clone();
|
||||
move || {
|
||||
move |cx| {
|
||||
cfg_if! {
|
||||
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
||||
if context.ready() {
|
||||
|
|
|
@ -124,7 +124,7 @@ impl DynChildRepr {
|
|||
/// Represents any [`View`] that can change over time.
|
||||
pub struct DynChild<CF, N>
|
||||
where
|
||||
CF: Fn() -> N + 'static,
|
||||
CF: Fn(Scope) -> N + 'static,
|
||||
N: IntoView,
|
||||
{
|
||||
id: crate::HydrationKey,
|
||||
|
@ -133,7 +133,7 @@ where
|
|||
|
||||
impl<CF, N> DynChild<CF, N>
|
||||
where
|
||||
CF: Fn() -> N + 'static,
|
||||
CF: Fn(Scope) -> N + 'static,
|
||||
N: IntoView,
|
||||
{
|
||||
/// Creates a new dynamic child which will re-render whenever it's
|
||||
|
@ -152,7 +152,7 @@ where
|
|||
|
||||
impl<CF, N> IntoView for DynChild<CF, N>
|
||||
where
|
||||
CF: Fn() -> N + 'static,
|
||||
CF: Fn(Scope) -> N + 'static,
|
||||
N: IntoView,
|
||||
{
|
||||
#[cfg_attr(
|
||||
|
@ -164,7 +164,7 @@ where
|
|||
fn create_dyn_view(
|
||||
cx: Scope,
|
||||
component: DynChildRepr,
|
||||
child_fn: Box<dyn Fn() -> View>,
|
||||
child_fn: Box<dyn Fn(Scope) -> View>,
|
||||
) -> DynChildRepr {
|
||||
#[cfg(all(target_arch = "wasm32", feature = "web"))]
|
||||
let closing = component.closing.node.clone();
|
||||
|
@ -189,7 +189,9 @@ where
|
|||
let _guard = span.enter();
|
||||
|
||||
let (new_child, disposer) =
|
||||
cx.run_child_scope(|cx| child_fn().into_view(cx));
|
||||
cx.run_child_scope(|cx| {
|
||||
child_fn(cx).into_view(cx)
|
||||
});
|
||||
|
||||
let mut child_borrow = child.borrow_mut();
|
||||
|
||||
|
@ -346,7 +348,7 @@ where
|
|||
|
||||
#[cfg(not(all(target_arch = "wasm32", feature = "web")))]
|
||||
{
|
||||
let new_child = child_fn().into_view(cx);
|
||||
let new_child = child_fn(cx).into_view(cx);
|
||||
|
||||
**child.borrow_mut() = Some(new_child);
|
||||
}
|
||||
|
@ -361,7 +363,7 @@ where
|
|||
let component = create_dyn_view(
|
||||
cx,
|
||||
component,
|
||||
Box::new(move || child_fn().into_view(cx)),
|
||||
Box::new(move |cx| child_fn(cx).into_view(cx)),
|
||||
);
|
||||
|
||||
View::CoreComponent(crate::CoreComponent::DynChild(component))
|
||||
|
|
|
@ -120,7 +120,7 @@ where
|
|||
|
||||
impl<F, N> IntoView for F
|
||||
where
|
||||
F: Fn() -> N + 'static,
|
||||
F: Fn(Scope) -> N + 'static,
|
||||
N: IntoView,
|
||||
{
|
||||
#[cfg_attr(
|
||||
|
@ -152,7 +152,7 @@ where
|
|||
instrument(level = "trace", name = "ReadSignal<T>", skip_all)
|
||||
)]
|
||||
fn into_view(self, cx: Scope) -> View {
|
||||
DynChild::new(move || self.get()).into_view(cx)
|
||||
DynChild::new(move |cx| self.get()).into_view(cx)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "stable")]
|
||||
|
@ -165,7 +165,7 @@ where
|
|||
instrument(level = "trace", name = "RwSignal<T>", skip_all)
|
||||
)]
|
||||
fn into_view(self, cx: Scope) -> View {
|
||||
DynChild::new(move || self.get()).into_view(cx)
|
||||
DynChild::new(move |cx| self.get()).into_view(cx)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "stable")]
|
||||
|
@ -178,7 +178,7 @@ where
|
|||
instrument(level = "trace", name = "Memo<T>", skip_all)
|
||||
)]
|
||||
fn into_view(self, cx: Scope) -> View {
|
||||
DynChild::new(move || self.get()).into_view(cx)
|
||||
DynChild::new(move |cx| self.get()).into_view(cx)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "stable")]
|
||||
|
@ -191,7 +191,7 @@ where
|
|||
instrument(level = "trace", name = "Signal<T>", skip_all)
|
||||
)]
|
||||
fn into_view(self, cx: Scope) -> View {
|
||||
DynChild::new(move || self.get()).into_view(cx)
|
||||
DynChild::new(move |cx| self.get()).into_view(cx)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "stable")]
|
||||
|
@ -204,7 +204,7 @@ where
|
|||
instrument(level = "trace", name = "MaybeSignal<T>", skip_all)
|
||||
)]
|
||||
fn into_view(self, cx: Scope) -> View {
|
||||
DynChild::new(move || self.get()).into_view(cx)
|
||||
DynChild::new(move |cx| self.get()).into_view(cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue