Recall & Review
beginner
What are route parameters in React Router?
Route parameters are dynamic parts of a URL that allow you to capture values from the URL and use them inside your React components.
Click to reveal answer
beginner
How do you define a route parameter in a React Router path?
You define a route parameter by adding a colon (:) before a name in the path, like
/user/:id. The :id is the parameter.Click to reveal answer
beginner
How do you access route parameters inside a React component?
You use the
useParams() hook from React Router. It returns an object with all route parameters as keys and their values from the URL.Click to reveal answer
beginner
Why are route parameters useful in web apps?
They let you create pages that change based on the URL, like showing details for different users or products without making separate routes for each.Click to reveal answer
beginner
Example: What will
useParams() return if the URL is /product/42 and the route is /product/:productId?It will return
{ productId: '42' }, so you can use productId inside your component to show product details.Click to reveal answer
How do you declare a route parameter in React Router?
✗ Incorrect
Route parameters are declared by prefixing the name with a colon (:), for example /user/:id.
Which React Router hook lets you access route parameters inside a component?
✗ Incorrect
The useParams() hook returns an object with the current route parameters.
If your route path is /post/:postId and the URL is /post/10, what is the value of postId from useParams()?
✗ Incorrect
The postId parameter captures the value 10 from the URL.
Why use route parameters instead of separate routes for each item?
✗ Incorrect
Route parameters let you handle many dynamic pages with a single route definition.
What type of value does useParams() return?
✗ Incorrect
useParams() returns an object where keys are parameter names and values are strings from the URL.
Explain how to use route parameters in React Router to show dynamic content based on the URL.
Think about how URLs like /user/123 can show different user info.
You got /3 concepts.
Describe the benefits of using route parameters in a React app.
Consider how many pages you can create with one route.
You got /4 concepts.