react-router-config-name
a simple module for react-router4 what can get router message by using the name property
install
npm install --save react-router-config-name
usage
- define your router array.
let routers = [
{
path: '/app',
component: App,
name: 'app',
}
];
- init the routers message.
import { setRouters } from 'react-router-config-name';
setRouters(routers);
- get router message whar you need by use the name property.
import { getRouteByName } from 'react-router-config-name';
const AppRoute = getRouteByName('app');
- use route in
<Route/>
tag.
import { Route } from 'react-router-dom';
...
<Route
key={AppRoute.path}
path={AppRoute.path}
component={AppRoute.component}
/>