Skip to content

Instantly share code, notes, and snippets.

@debugwand
Created March 11, 2016 16:59
Show Gist options
  • Save debugwand/d13ded09fabb2ef2ff4d to your computer and use it in GitHub Desktop.
Save debugwand/d13ded09fabb2ef2ff4d to your computer and use it in GitHub Desktop.
Dynamically-created nav built from react routes
import React from 'react';
import { Link } from 'react-router';
export default class App extends React.Component {
render() {
return (
<nav>
<ul>
{
this.props.routes[0].childRoutes.map ( (route) => {
return <li><Link to={route.path}>{route.component.name}</Link></li>
})
}
</ul>
{this.props.children}
</nav>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment