Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console error "closure invoked recursively or destroyed already" when setting signal checked in the conditional. #577

Closed
godstail opened this issue Feb 14, 2023 · 2 comments
Labels
A-reactivity Area: reactivity and state handling A-view Area: view! macro C-bug Category: bug, something isn't working

Comments

@godstail
Copy link

In example component every click on the button produces console error:

#[component]
fn MyComponent<G: Html>(cx: Scope) -> View<G> {
    let bool_sig = create_signal(cx, false);
    view! { cx,
        button(on:click = |_| {
            bool_sig.set(true);
        }) {
            "set true"
        }
        (if *bool_sig.get() {
            "true"
        } else {
            "false"
        })
    }
}

Sycamore 0.8.2 (with Perseus 0.4.0-beta17 or 18), Chrome.

Workaround:
Adding wrapping div inside view! removes error:

#[component]
fn MyComponent<G: Html>(cx: Scope) -> View<G> {
    let bool_sig = create_signal(cx, false);
    view! { cx,
        div {
            button(on:click = |_| {
                bool_sig.set(true);
            }) {
                "set true"
            }
            (if *bool_sig.get() {
                "true"
            } else {
                "false"
            })
        }
    }
}
@lukechu10 lukechu10 added C-bug Category: bug, something isn't working A-reactivity Area: reactivity and state handling A-view Area: view! macro labels Feb 16, 2023
@wingertge
Copy link
Contributor

This sounds like exactly like the bug fixed in #573

@lukechu10
Copy link
Member

Just tested this in 0.9.0-beta.2 and seems to have been fixed by reactivity v3 (#612) so I shall tentatively close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-reactivity Area: reactivity and state handling A-view Area: view! macro C-bug Category: bug, something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants