mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
finish error boundary (fix last state transition issue)
This commit is contained in:
parent
6c2469ec3a
commit
992e2bce78
3 changed files with 16 additions and 22 deletions
|
@ -2,7 +2,7 @@ use leptos::{component, create_signal, prelude::*, view, IntoView};
|
|||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
let (value, set_value) = create_signal(Ok(0));//"".parse::<i32>());
|
||||
let (value, set_value) = create_signal(Ok(0)); //"".parse::<i32>());
|
||||
let guard = value.read();
|
||||
|
||||
view! {
|
||||
|
@ -44,7 +44,8 @@ pub fn App() -> impl IntoView {
|
|||
// and render nothing and trigger the error boundary
|
||||
// if it is `Err`. It's a signal, so this will dynamically
|
||||
// update when `value` changes
|
||||
<strong>{move || value.get()}</strong>
|
||||
{move || value.get()}
|
||||
//<strong>{move || value.get()}</strong>
|
||||
</p>}
|
||||
.catch(|e| view! {
|
||||
<p class="error">{e.to_string()}</p>
|
||||
|
|
|
@ -88,7 +88,6 @@ where
|
|||
if let Some(parent) = &parent {
|
||||
parent.mark_check();
|
||||
}
|
||||
crate::log("HERE");
|
||||
return value.try_build().map_err(Some);
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +131,7 @@ where
|
|||
self,
|
||||
state: &mut Self::FallibleState,
|
||||
) -> Result<(), Self::Error> {
|
||||
crate::log("RenderEffect::try_rebuild");
|
||||
if let Some(inner) = &mut state.0 {
|
||||
inner
|
||||
.with_value_mut(|value| match value {
|
||||
|
|
|
@ -155,10 +155,8 @@ where
|
|||
TryStateState::Success(old) => {
|
||||
let old_unwrapped =
|
||||
old.as_mut().expect("children removed before expected");
|
||||
crate::log("rebuilding successful version");
|
||||
if let Err(e) = self.child.try_rebuild(old_unwrapped) {
|
||||
old_unwrapped.unmount();
|
||||
drop(old_unwrapped);
|
||||
let mut new_state = (self.fal)(e).build();
|
||||
Rndr::mount_before(&mut new_state, marker);
|
||||
Some(Err((old.take(), new_state)))
|
||||
|
@ -177,24 +175,19 @@ where
|
|||
Some(Ok(new_state))
|
||||
}
|
||||
},
|
||||
TryStateState::SubsequentFail {
|
||||
ref mut children,
|
||||
fallback,
|
||||
} => match self.child.try_rebuild(
|
||||
children.as_mut().expect("children removed before expected"),
|
||||
) {
|
||||
Err(e) => {
|
||||
(self.fal)(e).rebuild(fallback);
|
||||
None
|
||||
TryStateState::SubsequentFail { fallback, .. } => {
|
||||
match self.child.try_build() {
|
||||
Err(e) => {
|
||||
(self.fal)(e).rebuild(fallback);
|
||||
None
|
||||
}
|
||||
Ok(mut new_children) => {
|
||||
fallback.unmount();
|
||||
Rndr::mount_before(&mut new_children, marker);
|
||||
Some(Ok(new_children))
|
||||
}
|
||||
}
|
||||
Ok(()) => {
|
||||
fallback.unmount();
|
||||
Rndr::mount_before(children, marker);
|
||||
Some(Ok(children
|
||||
.take()
|
||||
.expect("children removed before expected")))
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
match res {
|
||||
Some(Ok(new_children)) => {
|
||||
|
|
Loading…
Reference in a new issue