Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's the diff between react router and react-router-dom?


Asked by Journey Bernard on Dec 10, 2021 React



In RRv4 you won't need to pass down browserHistory, that was just for previous versions of the router. Just use react-router-dom - react-router-dom re-exports all of react-router. The link on GitHub answer ( what's the diff between react-router-dom & react-router?
Indeed,
react-router-dom is used to do the route in react. react-router-dom provides switch and Link which are very useful to route the components In react.
Moreover, For navigation on click of a button you can use Redirect from react-router-dom package. I think as per my knowledge most of the tutorials and documents use the alias of BrouserRouter as Router otherwise there is nothing specific definition for Router in react-routing its just another name of BrouserRouter and for full explanation you can visit here
One may also ask,
Installing React Router: React Router can be installed via npm in your React application. Follow the steps given below to install Router in your React application: Step 1: cd into your project directory i.e geeks. After installing react-router-dom, add its components to your React application.
In this manner,
2. path: Path specifies a pathname we assign to our component. 3. component: It refers to the component which will render on matching the path. Note: By default, routes are inclusive which means more than one Route component can match the URL path and render at the same time.