DioxusLabs / DioxusLabs/dioxus
enhancement: Implement memoization by value of `Element`s passed as props
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**Problem**
When a component re runs and is passing an `Element` to another component, this other component will always rerun, because Dioxus can't seem to be able to memoize `Element`s.
```rs
fn app() -> Element {
let mut show = use_signal(|| false);
println!("Why am I running?");
rsx!(
div {
onclick: move |_| {
*show.write() = true;
},
p { "{show}" }
Whatever {
div { }
}
}
)
}
#[allow(non_snake_case)]
#[component]
fn Whatever(children: Element) -> Element {
println!("Why me too?");
rsx!(
div {
{children}
}
)
}
```
**Steps To Reproduce**
Steps to reproduce the behavior:
- Run it
**Expected behavior**
Only `println!("Why am I running?");` should run when the parent component re-runs if the passed children are still the same, right?
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environment:**
- Dioxus version: master
- Rust version: 1.75
- OS info: Windows
- App platform: any
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.