Skip to Content
Beginning React
book

Beginning React

by Andrea Chiarelli
July 2018
Beginner
96 pages
2h 8m
English
Packt Publishing
Content preview from Beginning React

Some Notes About the Route Component

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.

When the user requests a URL by clicking on the Link component, the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Test-Driven React

Test-Driven React

Trevor Burnham
Pro React 16

Pro React 16

Adam Freeman

Publisher Resources

ISBN: 9781789530520Supplemental Content