Last active
November 10, 2022 05:59
-
-
Save jatin510/7ff09f55d4b2551fee4e0f1335319663 to your computer and use it in GitHub Desktop.
Navigation in React
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 React from "react"; | |
import { BrowserRouter, Routes, Route, NavLink } from "react-router-dom"; | |
import Home from "./components/Home"; | |
import About from "./components/About"; | |
import Contact from "./components/Contact"; | |
function App() { | |
return ( | |
<> | |
<BrowserRouter> | |
<NavLink exact activeClassName="active" to="/" > | |
Home | |
</NavLink> | |
<NavLink exact activeClassName="active" to="/about" > | |
About | |
</NavLink> | |
<NavLink exact activeClassName="active" to="/contact" > | |
Contact | |
</NavLink> | |
<Routes> | |
<Route exact path="/" element={<Home />} /> | |
<Route exact path="/about" element={<About />} /> | |
<Route exact path="/contact" element={<Contact />} /> | |
</Routes> | |
</BrowserRouter> | |
</> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment