July 2018
Beginner
96 pages
2h 8m
English
Notice that the Route component has the path attribute (which allows us to specify the URL to map) and the component attribute (which allows us to assign the component to render in the current view):
<Switch><Route exact path='/' component={Catalog}/><Route path='/about' component={About}/></Switch>
The path attribute is used by React Router to detect the component to render, as specified by the corresponding component attribute.
In the previous route mapping, if we click on a Link component associated with the /about URL, the route with the root (/) path will match the starting part of /about, and the Catalog component will be rendered.