From the course: React Foundations by Pearson

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Defining parameterized routes

Defining parameterized routes - React.js Tutorial

From the course: React Foundations by Pearson

Defining parameterized routes

Right, well, now we're going to look at parameterized routes. You can define a parameterized route that looks like this. This part here is a placeholder for an actual ID. When the user navigates to a route like this, slash product slash one, for example, React will pattern match the route that we've navigated to against the route table. And it will notice that this bit corresponds to that section. And basically what it means is I want to display the product whose ID is one. Right, so our demo application has parameterized routes. If you click on the products link, then it basically gets all the products. And for each product, it'll generate a hyperlink. And these hyperlinks are like this, product one, product two, product three. So in each case, it'll take you to the product component and it'll pass either one or two or three as a parameter for the ID. Depending which link you click on, you're passing a different value for the ID. Okay, so in our demo application, we actually have two…

Contents