DioxusLabs / DioxusLabs/dioxus

issue: Counterintuitive spread of props

Open
#1,870 2 comments 1 reaction 1 assignee Claimed by @DogeDark View on GitHub
breaking bug consistency core tweak
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

Currently, spreaded props of Components will take over any children that you pass later, this aligns with Rust's way of spreading structs, but it might be counterintuitive for some users when used in Dioxus

Example:
```rs
#[component]
fn Button(children: Element, whatever: bool) -> Element {
rsx!(
{children}
)
}

fn app() -> Element {
rsx!(
Button {
..ButtonProps {
whatever: true,
children: None
},
p { "I don't exist :(" } // This won't exist
}
)
}
```

Workaround:

```rs
fn app() -> Element {
rsx!(
Button {
children: rsx!(
p { "I exist :)" } // This will exist
),
..ButtonProps {
whatever: true,
children: None
}
}
)
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.