dioxus
dioxus copied to clipboard
Memos can give out of date values
Problem
You can read an out of date value from a memo if you update a dependency and then immediately read the memo
Steps To Reproduce
- Create a memo
- Update a state the memo depends on
- Read an out of date value from the memo
use dioxus::prelude::*;
fn main() {
launch(app);
}
fn app() -> Element {
let mut count = use_signal(|| 0);
let mut signal = use_signal(|| 0);
let memo = use_memo({
to_owned![counter];
move || {
counter.borrow_mut().effect += 1;
println!("Signal: {:?}", signal);
signal()
}
});
assert_eq!(memo(), 0);
signal += 1;
assert_eq!(memo(), 1);
None
}
Expected behavior
Memos should always have up to date values
Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
- Dioxus version:
master - Rust version:
nightly - OS info: MacOS
- App platform:
hooks
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