Reputation: 915
I am new to React and was learning how to properly use React Router with React all together. As you know, the React Router was divided into three packages: react-router, react-router-dom and react-router-native. So, both react-router-dom and react-router-native by default have react-router inside of them. The question is since both react-router-dom and react-router-native include react-router then what is the reason to have react-router as separate package?
Upvotes: 2
Views: 91
Reputation: 9779
react-router-dom
is rewritten from react-router
it means react-router
is older version.
so for react router follow latest one react-router-dom
for your reference you can check this which has all the differences.
Upvotes: 0
Reputation: 1182
Quoting from here:
This package [react-router] provides the core routing functionality for React Router, but you might not want to install it directly. If you are writing an application that will run in the browser, you should instead install react-router-dom. Similarly, if you are writing a React Native application, you should instead install react-router-native. Both of those will install react-router as a dependency.
So extracting the core functionality into a standalone package can be useful for experimenting, developing, or testing improvements or features that can then be used in the specific packages.
Upvotes: 2