Created
April 6, 2017 17:44
-
-
Save syang/3bbdbd2b4f6e33c9ae5fcff352787ebf to your computer and use it in GitHub Desktop.
a working react-router with navbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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