Skip to content

Question: Reset ErrorBoundary outside handle_error #5288

@canyon-service

Description

@canyon-service

In the second example "Resetting the error boundary"
Why does handle_error closure not allow any mutation as I would like the reset (errors: ErrorContext [errors.clear_errors()]) to be handled outside the ErrorBoundary.

fn App() -> Element {
    let mut multiplier = use_signal(|| String::new());
    let mut rst: Signal<Option<ErrorContext>> = use_signal(|| None);
    rsx! {
        input {
            r#type: "text",
            value: multiplier,
            oninput: move |e| multiplier.set(e.value())
        }
        ErrorBoundary {
            handle_error: |errors: ErrorContext| {
                multiplier.set("mutate".to_string()); // Not allowed
                rst.set(Some(errors.clone())); // Not allowed, to be reset by external
                rsx! {
                    div {
                        "Oops, we encountered an error. Please report {errors:?} to the developer of this application"
                    }
                }
            },
            Counter {
                multiplier
            }
        }
    }
}

https://docs.rs/dioxus/latest/dioxus/prelude/fn.ErrorBoundary.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions