dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Returning Early RSX Causes an Error on Desktop Windows

Open DogeDark opened this issue 1 year ago • 1 comments

Problem

When running a Desktop app on Windows 10, early RSX returns are not rendered and an error is shown 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.

Screenshots

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

image

Environment:

  • Dioxus version: main, 0.5
  • Rust version: 1.77.1
  • OS info: Windows 10
  • App platform: Desktop

DogeDark avatar Apr 02 '24 20:04 DogeDark

~~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.

DogeDark avatar Apr 03 '24 21:04 DogeDark