Skip to content

Instantly share code, notes, and snippets.

@syang
Created April 6, 2017 17:44
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 syang/3bbdbd2b4f6e33c9ae5fcff352787ebf to your computer and use it in GitHub Desktop.
Save syang/3bbdbd2b4f6e33c9ae5fcff352787ebf to your computer and use it in GitHub Desktop.
a working react-router with navbar
// snippets in index.js (where everything gets started)
// ....
render(
(
<BrowserRouter>
<div>
<Navbar/>
<Route exact path="/" component={Feeds}/>
<Route path="/repo" component={Repos}/>
<Route path="/about" component={About}/>
</div>
</BrowserRouter>
),
document.getElementById('root')
);
-----------------
// snippets in navbar.js
// ...
class Navbar extends Component {
constructor() {
super();
injectTapEventPlugin();
}
static childContextTypes = {
muiTheme: React.PropTypes.object
}
getChildContext() {
return {
muiTheme: getMuiTheme()
}
}
render () {
return (
<Tabs>
<Tab
icon={<ActionHome />}
label="Feed"
containerElement={<Link to="/"/>}
/>
<Tab
icon={<MapsPersonPin />}
label="FAVORITES"
containerElement={<Link to="/repos"/>}
/>
<Tab
icon={<ContentInbox />}
label="Inbox"
containerElement={<Link to="/about"/>}
/>
</Tabs>
);
}
}
-----------------------------------
// snippets in feeds.js
import React, { Component } from 'react';
class Feeds extends Component {
render () {
return (
<div className='main-container'>
<p> this is the feeds page: </p>
<p> be patient and read a lot of fun feeds ...</p>
</div>
);
}
}
export default Feeds;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment