Created
October 9, 2023 16:59
-
-
Save itsmacr8/9dd1be2f0d1c1d6d007315e8ab4de24d to your computer and use it in GitHub Desktop.
How to use react router library for navigation.
This file contains 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
import {Routes, Route, Link} from 'react-router-dom' | |
import Homepage from './Homepage'; | |
import AboutMe from './AboutMe'; | |
function App() { | |
return( | |
<div> | |
<nav> | |
<Link to="/">Homepage</Link> | |
<Link to="/about-me">About Me</Link> | |
</nav> | |
<Routes> | |
<Route path="/" element={<Homepage />} /> | |
<Route path="/about-me" element={<AboutMe />} /> | |
</Routes> | |
</div> | |
); | |
} |
This file contains 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
import ReactDom from 'react-dom/client'; | |
import { BrowserRouter } from 'react-router-dom' | |
import App from './App'; | |
const root = ReactDom.createRoot(document.getElementById('root')); | |
root.render( | |
<BrowserRouter> | |
<App /> | |
</BrowserRouter> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment