Skip to content

Instantly share code, notes, and snippets.

@KrissieV
Last active February 7, 2017 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrissieV/b34a9d0fc42c64bd6f5b6be4ca11ccdb to your computer and use it in GitHub Desktop.
Save KrissieV/b34a9d0fc42c64bd6f5b6be4ca11ccdb to your computer and use it in GitHub Desktop.
// ReactRouter dynamic paths
var routes = (
<Router history={browserHistory} onUpdate={logPageView}>
<Route path="/" component={App} >
<IndexRoute component={Home} />
<Route path=":page" component={Page} />
</Route>
</Router>
)
// Excerpt from Page Component to match path with menu items
var pagePath = this.props.params.page;
var row = []
this.state.menuItems.items.map(function(item) {
var link = item.url.replace(siteVars.siteURL+'/','');
var path = link.replace('/','');
if (path == pagePath) {
row.push(<PageContents key={item.object_id} pageID={item.object_id} />);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment