You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered this problem a couple days ago as well.
The root cause of this problem is that attach_route_listener is a simple event listener that listens to popstate event which the same event is used for updating the route by the router so the callback can be called before the route is updated.
This can be mitigated by using Route::recognize() before a fix is available.
This can be fixed by making current route to be provided as a context value instead of held in a thread_local!.
This is the approach that react-router is using and it also enables rendering in a non-browser environment which could also be beneficial to the upcoming SSR.
I have updated the proposal in #2113 to make <Router /> a context provider.
voidpumpkin
changed the title
yew_router::attach_route_listener Event listener provides previuos route isntead of current
yew_router::attach_route_listener Event listener provides previuos route instead of current
Oct 24, 2021
Problem
yew_router::attach_route_listener Event listener provides previuos route isntead of current
Originally noticed in #2109
Steps To Reproduce
Steps to reproduce the behavior:
Use this repo: https://github.com/voidpumpkin/yew-playground/tree/stale-agents
Everytime you click a link, console shows
got X
and X is previous route instead of currentExpected behavior
expected to get current route
Screenshots
Environment:
master
]1.55
]Questionnaire
The text was updated successfully, but these errors were encountered: