Loading

Quipoin Menu

Learn • Practice • Grow

react / Route Parameters
mcq
Direction: Choose the correct option

Q1.

Given a route path '/user/:id', how do you extract the 'id' parameter in the component?
A. useRouteMatch().params.id
B. const { id } = useParams();
C. props.match.params.id
D. const id = useParam('id');
Direction: Choose the correct option

Q2.

What is a route parameter?
A. A prop passed to a route
B. A state object
C. A query string
D. A variable part of the URL path
Direction: Choose the correct option

Q3.

How do you access query parameters (like ?search=react) in React Router v6?
A. Using useLocation and parsing search string
B. Using useQueryParams hook
C. Using props.location.query
D. Using useParams
Direction: Choose the correct option

Q4.

Which of the following is a valid path with a parameter?
A. /user/:id
B. /user/[id]
C. /user/<id>
D. /user/{id}
Direction: Choose the correct option

Q5.

What happens if you navigate to '/user/123' and the route is '/user/:id'?
A. It redirects to 404
B. The component receives param id = 123 as number
C. The component receives param id = '123'
D. The route doesn't match