Skip to content

subscriber did not re-rendered in class component when context-update, and element can have multiple onclick method #2280

@usagrada

Description

@usagrada

Problem

Class Component did not re-render, but Functional Component did re-render, when providing context is changed, to put it like React Component.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

First, clone My Repository and run app(you may think filename(in-repo) is strange, don't worry about it.).

git clone https://github.com/usagrada/yew-todo-app.git
git checkout 23f46839197dca3ec7588dcd42a3b63f3348b919
trunk serve --open

Then, click the upper table and also click the lower table.
Then, open the code of src/pages/museum.rs and comment out lines 147 & 150.
After this comment-out, the class component's table was not re-rendered.

It is strange that td tag allows to have two onclick methods, I thought.

            // let update = ctx.link().callback(|_| MuseumProviderMessage::Msg);
            html! {
              <td
                // onclick={update}
                onclick={&click}
              >
                {field.state[i][j]}
              </td>
            }

Expected behavior
A clear and concise description of what you expected to happen.
class component runs equally to the function component, not emit message in subscribed component
FieldView

Screenshots
If applicable, add screenshots to help explain your problem.
each table was 1 clicked
img

Environment:

  • Yew version: [v0.19.3]
  • Rust version: [1.59.0, nightly]

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

    S-waiting-on-authorStatus: awaiting action from the author of the issue/PRbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions