liveBook · Manning

React Router

As explained in React Hooks in Action: With Suspense and Concurrent Mode

React Router is a library of React components and APIs for managing client-side navigation and route matching.

React Router connects URLs to React components so client-side navigation updates the displayed page without treating each route as a separate application. section 10.1

Build navigation incrementally:

  • Declare routes with Routes and Route, including paths such as /bookings, /bookables, and /users. section 10.1
  • Nest routes to organize related UI, and use a trailing wildcard when a parent route owns deeper paths. section 10.4
  • Put dynamic values after a colon, read them with useParams, navigate programmatically with useNavigate, and manage query strings with useSearchParams. section 10.4

Bookable details

A route such as /bookables/:id can render BookablesView; inside that component, const {id} = useParams() retrieves the selected bookable. A list can call navigate("/url/of/page") to move elsewhere. section 10.4

Table 10.1 The four components we’ll change in this section (view table figure)

Section

Component

Change

10.1.1

App

Setting up routes to enable nesting

10.1.2

BookablesPage

Adding nested routes to the Bookables page

10.1.3

BookablesView

Accessing URL parameters with the useParams hook

10.1.4

BookablesList

Navigating with the useNavigate hook

Use the component-change table to trace route setup, nested routes, parameter access, and navigation through the example application. section 10.1

How React Hooks in Action: With Suspense and Concurrent Mode covers it

How deep it goes
Explains route declarations, nesting, parameters, navigation, and query strings through focused application changes.
Examples
Uses a bookings application with Bookings, Bookables, and Users pages plus parameterized bookable and booking URLs.
What it assumes
Assumes familiarity with React components and hooks while demonstrating routing APIs through an existing application.
What you can do after
Build route-driven React pages, read URL values, navigate programmatically, and update query-string parameters.
How it connects
Connects React components with client-side navigation, nested routes, URL parameters, query strings, and hooks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of React Hooks in Action: With Suspense and Concurrent Mode. The section links point to the parts of the book it draws on.