Closed Boscop closed 4 years ago
Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.
Yeah I agree. I can’t verify it right now but we may find a manual way for the user to trigger the routing based on the initial route. I think both are valid use cases:
Yes, it's good to let users control this. E.g. If upon pageload, url and Default
route differ, the app might want to set the url to match the Default
route, instead of the other way round.
The app would do it in the create
method:
I realized, it's possible already, without any changes to yew-router, I updated my history_state
example to do this:
It now does router_agent.send(yew_router::Request::GetCurrentRoute);
in RootComponent::create()
.
But if upon pageload the url is invalid, and ends up mapping to the Default
route, currently it doesn't set the url to match that route.
Yeah cool. I also was not sure if the feature belongs to yew-router, but we could provide some helper methods or a setting to specify the behavior from the user side... :)
Currently, when the app is loaded, the
Default
route is active, even if the URL says otherwise. E.g. you can see it in my example here: https://github.com/saschagrunert/yew-router/pull/213. If the user came to the page by entering a certain url, we should route to it upon pageload. Not sure what the best event to listen to is, for this. E.g. there isDOMContentLoaded
which fires beforeload
(not waiting for assets to load). Not sure ifDOMContentLoaded
will fire before our wasm app is started, and if we register a handler for it in the wasm app, if we still catch the event that was fired before.. Related: https://stackoverflow.com/questions/2414750/difference-between-domcontentloaded-and-load-events https://stackoverflow.com/questions/7745124/event-which-triggers-before-domcontentloaded