0% found this document useful (0 votes)
11 views

React Router Dom

heyyyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

React Router Dom

heyyyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

React Router Dom

Installing router dom command


npm install react-router-dom
 IMPORT ROUTING Packages
Following are Routing import Packages
import { BrowserRouter as Router,Route,Link,Routes} from "react-router-dom";
This file is import for the router Dom and also import Navigation file for the navigate
Ex: - import About from "./About";

Totally code:-
<Router>
<div>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>

</ul>
</nav>
<Routes>

<Route path="/about" element={ <About />}> </Route>

</Routes>
</div>
</Router>
Page code: -
import React from "react";
import { BrowserRouter as Router,Route,Link,Routes} from "react-router-dom";
import About from "./About";
function Navbar(){
return(
<Router>
<div>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>

</ul>
</nav>
<Routes>

<Route path="/about" element={ <About />}> </Route>

</Routes>
</div>
</Router>
)
}
export default Navbar;

You might also like