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

Iterator of rsx blocks causes signals/elements to affect unrelated things (strange behavior) even when key is set #3019

Open
1 of 3 tasks
Andrew15-5 opened this issue Sep 30, 2024 · 1 comment
Labels
bug Something isn't working needs reproduction An issue that is missing a reproduction rsx Related to rsx or the dioxus-rsx crate

Comments

@Andrew15-5
Copy link
Contributor

Problem

First mentioned.

Each slider has a corresponding i32 signal and a few other things (reset button, oninput/onclick).

This works correctly:

    Slider {
        ...
    }
    Slider {
        ...
    }
    Slider {
        ...
    }

But this:

    {
        [ // Slice of tuples.
            (..., ...),
            (..., ...),
            (..., ...),
        ].into_iter().map(|(name, ...)| rsx! {
            Slider {
                name: name,
                ...
            }
        })
    }

causes some weird state/behavior issues. I even added the key:

#[component]
fn Slider(
    SliderProps {
        name,
    }: SliderProps,
) -> Element {
    rsx! {
        div {
            key: name,

I basically copied this:

// Iterators within expressions
{
let data = std::collections::HashMap::<&'static str, &'static str>::new();
// Iterators *should* have keys when you can provide them.
// Keys make your app run faster. Make sure your keys are stable, unique, and predictable.
// Using an "ID" associated with your data is a good idea.
data.into_iter().map(|(k, v)| rsx!(li { key: "{k}", "{v}" }))
}

Steps To Reproduce

Can't yet do that.

Steps to reproduce the behavior:

Expected behavior

Each slider must only affect stuff related to itself, not other sliders too.

Environment:

  • Dioxus version: dioxus 0.6.0-alpha.2 (0d33c40)
  • Rust version: rustc 1.82.0-nightly (c1a6199e9 2024-07-24)
  • OS info: Pop!_OS
  • App platform: fullstack

Questionnaire

  • 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
@matthunz matthunz added bug Something isn't working rsx Related to rsx or the dioxus-rsx crate needs reproduction An issue that is missing a reproduction labels Oct 1, 2024
@matthunz
Copy link
Contributor

matthunz commented Oct 1, 2024

This could be a bug with the VNode iterator in dioxus-rsx. I haven't been able to reproduce this exact issue though, it'd be great to see more of the code 👀

Possibly related #3021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction An issue that is missing a reproduction rsx Related to rsx or the dioxus-rsx crate
Projects
None yet
Development

No branches or pull requests

2 participants