Router 1

Router

$ npm install --save react-router-dom

Here is what the above code is Doing:
1. We’re importing the BrowserRouter, Route, and Link components from the react-router-dom package.
2. We’re wrapping our App component in a BrowserRouter component.
3. We’re creating two Route components. The first one has a path of “/” and will render the Home component. The second one has a path of “/about” and will render the About component.
4. We’re creating two Link components. The first one has a to prop set to “/” and will render a link to the Home component. The second one has a to prop set to “/about” and will render a link to the About component.

Similar Posts