Routing in react
Routing in React enables navigation between different views without full page reloads. React Router is the most popular library, providing components like Route, Link, and hooks like useNavigate and useParams for building single-page applications with multiple views.
Example
import { BrowserRouter, Routes, Route, Link } from 'react-router-dom';
function App() {
return (
<BrowserRouter>
<nav><Link to="/about">About</Link></nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
</Routes>
</BrowserRouter>
);
}React Router handles client-side routing, mapping URL paths to components.