课程: React: Creating and Hosting a Full-Stack Site

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

URL parameters with React Router

URL parameters with React Router

- [Instructor] All right, so at this point, we have a NavBar that allows us to go to three of the pages in our application, but we still need to be able to access the individual ArticlePage and display multiple articles using that page. So here's how this is going to work. First of all, we're going to need to go back to our app component, and the routes that we defined, and make a slight change to the path that we defined for our ArticlePage. Instead of saying /articles/individual, we're going to say /articles/, and then we're going to use a colon followed by name, all right? Now, this is what's referred to as a URL parameter, or a route parameter, and basically, what this colon name thing allows us to do is catch all routes that start with articles and have something else after them, so, in our case, this could be /articles/123, or if it's the article's name, as you'll often see on blog sites, such as /articles/learn-node, for example, or /learn-react, then this page is going to be…

内容