react-router-to-array-of-object
v0.1.4
Published
Convert your react router component to an array of objet {name: 'route name', path: 'route path'}
Downloads
14
Maintainers
Readme
Small package to return array of object, each object with following structure:
{name: 'route name', path: 'route path'}
Install
npm i --save react-router-to-array-of-object
Usage
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import routesToArray from 'react-router-to-array-of-object';
const appRoutes = (
<Route path="/admin" name={admin} getComponents={require('./admin').default}>
<IndexRoute name="Login" name={Login} getComponents={require('./Login').default}/>
<Route path="dashboard" name={Dashboard} getComponents={require('./Dashboard').default}/>
<Route path="dashboard/quiz-report" name={QuizReport} getComponents={require('./Dashboard/QuizReport').default}/>
<Route path="products" name={Products} getComponents={require('./Products').default}/>
</Route>
);
console.log(routesToArray(appRoutes));
/**
output:
[
{name:'admin' path: '/admin'},
{name:'Dashboard' path: '/dashboard'},
{name:'QuizReport' path: '/dashboard/quiz-report'},
{name:'Products' path: '/products'},
]
*/