State management and event handling interact badly leading to stale state
Problem When multiple events are handled without rerendering the state accessed in event callbacks is stale.
Steps To Reproduce Steps to reproduce the behavior:
- Clone https://github.com/mohe2015/yew-bug
(cd frontend && trunk serve)(cd tests && cargo run)- Open browser console in opened firefox (note: firefox will automatically close after 30 seconds)
Expected behavior
I expected the browser console to contain username: username, password: password but it contains username: username, password: (password missing). When clicking on the login button again the correct text is shown. This is only an issue in Firefox but not Chromium.
From the logs it seems like a rerender is required to update the value in the handle.
Screenshots
Environment:
- Yew version: 0.20 until master are all affected
- Rust version: nightly
- Build tool, if relevant: trunk
- OS, if relevant: Linux
- Browser and version, if relevant: Firefox
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
@mohe2015 I can work on this issue. Can I get it assigned as part of Hacktober fest 2025?
Btw I'm not a project member, so I can't help you with the hacktoberfest part. I think this project is relatively inactive currently.