@drawbotics/route
v2.0.0
Published
The main difference this route object has compared to [Route](https://reacttraining.com/react-router/web/api/Route) is that it accepts two extra props: `withProps` and `basePath`.
Downloads
18
Keywords
Readme
Route
The main difference this route object has compared to Route is that it accepts two extra props: withProps
and basePath
.
withProps
: An object containing extra props to be passed to the rendered route component.basePath
: Indicate to the rendered route and the children routes what's the base path of the parent.
Usage
An usage example:
import React from 'react';
import { Route } from '@drawbotics/route';
import MyRouteComponent from '../routes/MyRouteComponent';
class MyComponent extends React.Component {
render() {
return (
<Route
basePath="/parent-url"
path="/some-url"
withProps={{ title: 'The Title', items: [ /* ... */ ]
component={MyRouteComponent} />
);
}
}
Extra
A Switch
component with support for basePath
is also included. It's used exactly the same way as vanilla Switch
from react-router
.