Created
August 3, 2021 11:35
-
-
Save sarthakxv/9464104e222690c2385914e8b8cd3c9c to your computer and use it in GitHub Desktop.
Linking pages in React using react-router-dom package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // importing Router and Route | |
| import { BrowserRouter as Router, Route } from "react-router-dom"; | |
| // Pages we need to link | |
| import HomePage from "./Pages/HomePage/index"; | |
| import AlbumPage from "./Pages/AlbumPage/index"; | |
| import GalleryPage from "./Pages/GalleryPage/index"; | |
| // root App component | |
| const App = () => { | |
| return ( | |
| <div> | |
| <Router> | |
| <Route exact path="/" component={HomePage} /> | |
| <Route path="/albums" component={AlbumPage} /> | |
| <Route path="/albums/gallery" component={GalleryPage} /> | |
| </Router> | |
| </div> | |
| ); | |
| }; | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment