Route matching

At the moment, if you serve the application, nothing would have changed we've simply wrapped our app in BrowserRouter so that inside <BrowserRouter> we can define route matching components. Let's suppose we want the <RegistrationForm> component to only render when the route is /register, we can use a <Route> component:

...import { BrowserRouter, Route } from 'react-router-dom';ReactDOM.render((  <BrowserRouter>    <Route exact path="/register" component={RegistrationForm} />  </BrowserRouter>), document.getElementById('renderTarget'));

The <Route> component usually uses two props  path and component. If a <Route> component has a path prop that matches the current URL's path name (such as window.location.pathname), the component ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.