Skip to content

How to control Yew route from external JS in SPA? #3095

Answered by jq170727
jq170727 asked this question in Q&A
Discussion options

You must be logged in to vote

I found a way to do what I need by having

  • Yew render a div within a BrowserRouter
  • Yew add an EventListener on the div which changes the route when it sees a CustomEvent
  • A Javascript function dispatch a CustomEvent to the div when called

See example here: https://github.com/jq170727/change_yew_route_from_js

This works but I'm sure it could be improved. Suggestions or coding advice always appreciated 🙂

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jq170727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant