fix: <ErrorBoundary/> toggling between states (closes issue #820) (#957)

This commit is contained in:
Greg Johnston 2023-04-26 17:30:30 -04:00 committed by GitHub
parent 0f277c55ec
commit 0a65f43789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,18 +45,20 @@ where
provide_context(cx, errors);
// Run children so that they render and execute resources
let children = children(cx);
let children = children(cx).into_view(cx);
let errors_empty = create_memo(cx, move |_| errors.with(Errors::is_empty));
move || {
match errors.with(Errors::is_empty) {
true => children.clone().into_view(cx),
false => view! { cx,
if errors_empty.get() {
children.clone().into_view(cx)
} else {
view! { cx,
<>
{fallback(cx, errors)}
<leptos-error-boundary style="display: none">{children.clone()}</leptos-error-boundary>
</>
}
.into_view(cx),
.into_view(cx)
}
}
}