react-router vs react-router-dom, when to use one or the other?

前端 未结 4 1837
失恋的感觉
失恋的感觉 2020-12-07 10:00

Both have Route, Link, etc. When to use one or the other? I\'m really confused on where to use each one. Server side? Client side?

https://reacttraining.com/react-ro

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 10:53

    react-router contains all the common components between react-router-dom and react-router-native. When should you use one over the other? If you're on the web then react-router-dom should have everything you need as it also exports the common components you'll need. If you're using React Native, react-router-native should have everything you need for the same reason. So you'll probably never have to import anything directly from react-router. As far as when you use

    
    

    vs

    
    

    In RRv4 you won't need to pass down browserHistory, that was just for previous versions of the router.

    If you're still confused, you can check out the details on each package here

提交回复
热议问题