The Route
component allows a component to render when its predefined path matches the current URL. The Route
component and group of Route
components are wrapped inside the Routes
component.
<Route path="PATH" element={<*ELEMENT*/>} />
import {BrowserRouter , Routes, Route } from "react-router-dom";
function App() {
return (
<BrowserRouter >
<Routes>
<Route path="/" element={<Home />} /> //declaring route path and its element
<Route path="/about" element={<About />} />
<Route path="/contact" element={<Contact/>} />
</Routes>
</BrowserRouter>
);
}