DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.3k stars 735 forks source link

Updating RSX Too Fast Causes an Error on Desktop Windows #2229

Closed DogeDark closed 2 months ago

DogeDark commented 2 months ago

Problem

When running a Desktop app on Windows 10, updating RSX quickly after it was rendered causes an error in the console.

Steps To Reproduce

Run this component on the Dioxus Desktop platform in a Windows environment.

fn app() -> Element {
    let mut data = use_signal(|| false);

    if data() {
        println!("RAN1");
        rsx!("true")
    } else {
        println!("RAN2");
        data.set(true);
        rsx!("false")
    }
}

Expected behavior

true should be displayed instead of false and there should be no errors.

Screenshots

This error is shown in the console when the true branch of the if statement is run.

image

Environment:

DogeDark commented 2 months ago

This also happens with if, else if and else statements inside of RSX blocks:

fn app() -> Element {
    let mut data = use_signal(|| false);

    rsx! {
        if data() {
            "true"
        } else {
            {data.set(true)}
            "false"
        }
    }
}

Also happens on release.

Scratch this. It's not based on conditionals but rather seems based around how quickly a signal or hook is updated.