preactjs / preact-router

:earth_americas: URL router for Preact.
http://npm.im/preact-router
MIT License
1.01k stars 156 forks source link

withRouter? #401

Closed mellis481 closed 2 years ago

mellis481 commented 3 years ago

I have a scenario where I need to call route() in my application from a component that is outside of <Router>. When I do this, the ROUTERS array in the internal preact-router code is empty. I'm, therefore, concluding that route() will only work if called from a component within <Router>.

In react-router, I believe this would be a situation where the component that calls route() (that lives outside of <Router>) could simply be wrapped in withRouter and it would work.

How can I get route() to work outside of <Router> without withRouter?