React Router Navigation in React Apps

🚀 Day 9 of My React Learning Journey: React Router & Navigation Today I learned how to handle navigation in React using React Router 👇 🔹 What is React Router? React Router is a library used to handle routing in React applications. It allows navigation between different pages without reloading the browser. 🔹 What is Navigation? Navigation means moving between different pages or components in an application using links. ⚔️ React Router vs Navigation React RouterNavigationLibrary for routingAction of moving between pagesUses components like BrowserRouter, RouteUses links like <Link>Enables SPA behaviorImproves user experienceHandles URL-based routingSwitches UI without reload🔹 Simple Example (Using Both Concepts) import { BrowserRouter, Routes, Route, Link } from "react-router-dom"; function Home() { return <h1>Home Page 🏠</h1>; } function About() { return <h1>About Page ℹ️</h1>; } function App() { return ( <BrowserRouter> <nav> <Link to="/">Home</Link> |{" "} <Link to="/about">About</Link> </nav> <Routes> <Route path="/" element={<Home />} /> <Route path="/about" element={<About />} /> </Routes> </BrowserRouter> ); } export default App; 💡 My Takeaway: React Router helps build single-page applications by enabling smooth navigation without page reloads. 📌 Next, I’ll be learning about API Calls in React! 👉 Follow my journey as I learn React step by step 🚀 #React #JavaScript #ReactRouter #Frontend #WebDevelopment #LearningInPublic #100DaysOfCode

  • text

To view or add a comment, sign in

Explore content categories