I wonder if there's some way with React Router to get a list of all possible paths with the routes configuration?
For example, from this:
var routes = (
<Route name="/">
<DefaultRoute .../>
<Route name="about" .../>
<Route name="blog" .../>
</Route>
);
I'd like:
["/", "/about", "/blog"]
This seems to work for me, with v0.13:
var router = Router.create(routes);
var routePaths = [];
for (var i in router.namedRoutes) {
routePaths.push(router.namedRoutes[i].path);
}
//routePaths = ['/', '/about', '/blog']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With