Skip to content

State management and event handling interact badly leading to stale state #3796

Open
@mohe2015

Description

@mohe2015

Problem
When multiple events are handled without rerendering the state accessed in event callbacks is stale.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/mohe2015/yew-bug
  2. (cd frontend && trunk serve)
  3. (cd tests && cargo run)
  4. 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
Image

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

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions