Description
Describe the bug
I can spend some time diagnosing this issue in more depth if required.
I am using SSR (cargo-leptos) to render a view like this:
let ui = move || -> Result<_> {
let product: Product = db.read().get_product(id)?.read();
let product_stored_signal = Signal::stored(product); // making #[prop(into)] more explicit
Ok(view! { <ProductView product /> })
}
return view! {
<ErrorBoundary fallback=...>
{ui}
</ErrorBoundary/>
}
where the ProductView
derives a signal like this:
pub fn ProductView(product: Signal<Product>) -> impl IntoView {
let add_to_cart_info = Signal::derive(move || product.read().add_to_cart_info());
view! {
<AddToCartBtn info=add_to_cart_info />
}
}
But when I first load the page, I'm getting a signal disposed error inside the AddToCartBtn
, which reads the signal in an on:click handler, something like this:
pub fn AddToCartBtn(info: Signal<...>) -> impl IntoView {
let on_click =move || {
match info.try_get() {
Some(_) => ...,
None => warn!("Something fishy is about?") // THIS LINE keeps triggering for me
};
}
view! {
<button on:click=on_click>
</button>
}
}
When I remove the error boundary, however, everything seems to work fine
Leptos Dependencies
[features]
default = ["hydrate"]
hydrate = ["leptos/hydrate", "leptoaster/hydrate"]
ssr = [
"leptos_meta/ssr",
"leptos_router/ssr",
"leptos-use/ssr",
"leptos-use/axum",
"dep:axum",
"payments/support-server",
"leptoaster/ssr",
]
[dependencies]
leptos = { version = "0.7.0", features = ["delegation"] }
leptos_router = { version = "0.7.0" }
leptos_meta = { version = "0.7.0" }
leptos-use = { version = "0.15.5", features = ["use_window_scroll"] }
leptoaster = "0.2.1"
# on server crate, I'm using multi-workspace setup
leptos = { version = "0.7", features = ["ssr"] }
leptos_router = { version = "0.7.0" }
axum = { version = "0.7" }
leptos_axum = { version = "0.7.0" }
To Reproduce
I can make a repro if the above pseudo-code isn't enough
Expected behavior
I've been a bit wary of <ErrorBoundary />
I'm not going to lie, since I've moved from a trait extension pattern .map_view(|ok_data| ...)
which automatically renders the error case I've been having small problems like this more than I would like.
Additional context
I've been reading the https://book.leptos.dev/appendix_life_cycle.html book chapter on signals, and peeking at the internals of the error handling process, and I'm still a bit stuck how to fix this issue internal (to leptos) myself