Understanding route props
The react-router
, which is the <Route>
component, accepts the following props:
Route.propTypes= { computedMatch:PropTypes.object, path:PropTypes.string, exact:PropTypes.bool, strict:PropTypes.bool, sensitive:PropTypes.bool, component:PropTypes.func, render:PropTypes.func, children:PropTypes.oneOfType([PropTypes.func, PropTypes.node]), location:PropTypes.object };
- Exact props: To match the browser's
location.pathname
exactly with the<Route>
component's path, we can add the exact prop to the<Route>
, as follows:
<Route path="/admin" component={AdminComponent} exact />
- Strict props: For the strict prop,
react-router
ensures that<Route>
matches only if the URL has a trailing slash. This means that if strict props are used in theRoute
component,/admin/users/
will be matched, whereas/admin/users
will not be matched:
<Route path="/admin/" component={AdminComponent} strict />
- Sensitive props: The sensitive...