4IT580: Docs
4IT580 WebGitLab

3rd Practical Class:
Routing in React

🎯 Learning Objectives (5 minutes)

By the end of this session, you will be able to:

🤔 The Problem: Why Do We Need Client-Side Routing?

What happens without routing?

Problems with this approach:

🏗️ Building Blocks: React Router v7

Step 1: Basic Router Setup

React Router provides client-side routing for React applications:

Key Components:

Step 2: Exercise - Add a New Route

Your Turn! Add a new "Products" page to the router above.

⚡ Dynamic Routes and URL Parameters

Step 3: URL Parameters

React Router allows you to create dynamic routes with parameters:

Key Concepts:

🔒 Nested Routes and Layouts

Step 4: Layout Components

React Router supports nested routes for creating layouts:

Key Concepts:

🎯 Final Exercise: Build a Complete App

Your Challenge: Create a simple blog app with the following requirements:

  1. Routes:

    • Home page ()
    • Blog posts list ()
    • Individual post page ()
    • About page ()
  2. Features:

    • Navigation between pages
    • Dynamic routing for blog posts
    • Mock data for posts

📚 Additional Resources

Next Steps: Explore advanced routing features like route guards, lazy loading, and integration with state management libraries.