简体   繁体   中英

ReactJS navigation from service

In a ReactJS app I want to navigate to another route from a service.

I tried this approach trough an external history with createBrowserHistory but it would just change the url without updating the route.

I think I'm stuck through outdated info about mixed versions of both React and the router, anyone can tell me the current way to do that?

TIA

The issue was the version of the history npm library, as the latest one is compatible with react router v6 (which is still in beta). Downgrading to a previous version worked fine ( npm i history@4.10.1 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM