You are on page 1of 4

React Router: Parameters

Jogesh K. Muppala
React Router
• Paths specified as a URL
• Paths can also carry parameter values:
– e.g., /menu/42 where 42 is a route parameter
• Route parameters specified in the path
specification as a token
– e.g., path: ‘menu/:id’ where id is the token

2
Route Parameters
• Route parameters can be specified using a link parameter
while specifiyng the link
– e.g., <Link to{`/menu/${dish.id}`} >
• Route passes three props to the component:
– match, location, history

3
match Object
• match object provides information about how a <Route
path> matched the URL
– params: an object that contains key/value pair parsed from
the URL corresponding to the dynamic segments of the
path
– e.g. if path is specified as /menu/:id, then a path like
/menu/42 will result in match.params.id being equal to
“42”