Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yew router example main.rs component does not update html at all #2168

Closed
1 of 3 tasks
Tracked by #2052
voidpumpkin opened this issue Nov 21, 2021 · 3 comments · Fixed by #2179
Closed
1 of 3 tasks
Tracked by #2052

Yew router example main.rs component does not update html at all #2168

voidpumpkin opened this issue Nov 21, 2021 · 3 comments · Fixed by #2179
Assignees
Labels
A-yew-router Area: The yew-router crate bug

Comments

@voidpumpkin
Copy link
Member

Problem
Yew router example main.rs components does not update html at all on changes

Sadly right now I feel I would spend too much time debugging thus i created this bug report

Steps To Reproduce
Steps to reproduce the behavior:

  1. Start yew router example in mobile view
  2. click the burger
  3. nothing happens

Expected behavior
Menu opens

Screenshots
Peek 2021-11-21 14-11

Environment:

  • Yew version: [master]
  • Rust version: [1.56.0]
  • Build tool, if relevant: [trunk]

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
@futursolo
Copy link
Member

I think I might be the culprit who broke the router example while updating the router. :)

Would you mind to assign this to me?

@hamza1311
Copy link
Member

This seems to happen because the Router re-renders only if two (in this case) BrowserHistory are not equal

fn changed(&mut self, ctx: &Context<Self>) -> bool {
let link = ctx.link().clone();
if self.history != ctx.props().history {
self._listener = ctx
.props()
.history
.listen(move || link.send_message(Msg::ReRender));
self.history = ctx.props().history.clone();
true
} else {
false
}
}

which is never true (they're always equal):

impl PartialEq for BrowserHistory {
fn eq(&self, _rhs: &Self) -> bool {
// All browser histories are created equal.
true
}
}

@hamza1311
Copy link
Member

hamza1311 commented Nov 21, 2021

Would you mind to assign this to me?

Sure, take it

@hamza1311 hamza1311 added the A-yew-router Area: The yew-router crate label Nov 21, 2021
@futursolo futursolo mentioned this issue Nov 22, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-router Area: The yew-router crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants