dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Component with `key` attribute does not pass a `ReadOnlySIgnal<bool>` attribute properly

Open rogusdev opened this issue 1 year ago • 2 comments

Problem

With latest main in web, this app will display falsefalse when I would expect truefalse. Specifically, the is_on: true is not getting passed or getting ignored when there is a key on the component.

#![allow(non_snake_case)]

use dioxus::prelude::*;

#[derive(Clone, Routable, Debug, PartialEq)]
enum Route {
    #[route("/")]
    Home {},
}

fn main() {
    launch(App);
}

fn App() -> Element {
    rsx! {
        Router::<Route> {}
    }
}

#[component]
fn Comp(
    is_on: ReadOnlySignal<bool>,
) -> Element {
    rsx! {
        "{is_on()}"
    }
}

#[component]
fn Home() -> Element {
    rsx! {
        Comp {
            key: "A",
            is_on: true,
        }
        Comp {
            key: "B",
            is_on: false,
        }
    }
}

If you remove the key from the first Comp it will display what I would expect: truefalse. But I need to have a key on these elements.

Environment:

  • Dioxus version: main
  • App platform: web

Questionnaire

  • [x] I'm interested in fixing this myself but don't know where to start
  • [ ] I would like to fix and I have a solution
  • [ ] I don't have time to fix this right now, but maybe later

rogusdev avatar Aug 22 '24 23:08 rogusdev

I think this is a bug in hot reloading. The code snippet you posted does work in release mode

ealmloff avatar Aug 26 '24 13:08 ealmloff

cargo.toml for consideration:

[dependencies]
dioxus = { path = "../dioxus/packages/dioxus", features = ["web", "router"] }
dioxus-logger = "0.5.1"

rogusdev avatar Aug 26 '24 16:08 rogusdev