Created
April 5, 2016 18:37
-
-
Save dabit3/5a75ecdba89dc2a45c1aaaf2727ddad1 to your computer and use it in GitHub Desktop.
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
import React, { Component } from 'react' | |
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router' | |
class App extends Component { | |
render () { | |
return ( | |
<Router history={hashHistory}> | |
<Route path='/' component={Container}> | |
<IndexRoute component={Home} /> | |
<Route path='/address' component={Address}> | |
<IndexRoute component={TwitterFeed} /> | |
<Route path='instagram' component={Instagram} /> | |
</Route> | |
<Route path='/about' component={About} /> | |
<Route path='/namedComponent' component={NamedComponents}> | |
<IndexRoute components={{ title: Title, subTitle: SubTitle }} /> | |
</Route> | |
<Route path='*' component={NotFound} /> | |
</Route> | |
</Router> | |
) | |
} | |
} | |
const Title = () => ( | |
<h1>Hello from Title Component</h1> | |
) | |
const SubTitle = () => ( | |
<h1>Hello from SubTitle Component</h1> | |
) | |
const NamedComponents = (props) => ( | |
<div> | |
{props.title}<br /> | |
{props.subTitle} | |
</div> | |
) | |
const Nav = () => ( | |
<div> | |
<IndexLink activeClassName='active' to='/'>Home</IndexLink> | |
<IndexLink activeClassName='active' to='/address'>Address</IndexLink> | |
<IndexLink activeClassName='active' to='/about'>About</IndexLink> | |
<IndexLink activeClassName='active' to='/namedComponent'>Named Components</IndexLink> | |
</div> | |
) | |
const Container = (props) => <div> | |
<Nav /> | |
{props.children} | |
</div> | |
const Home = () => <h1>Hello from Home!</h1> | |
const Address = (props) => <div> | |
<br /> | |
<Link to='/address'>Twitter Feed</Link> | |
<Link to='/address/instagram'>Instagram Feed</Link> | |
<h1>We are located at 555 Jackson St.</h1> | |
{props.children} | |
</div> | |
const Instagram = () => <h3>Instagram Feed</h3> | |
const TwitterFeed = () => <h3>Twitter Feed</h3> | |
const About = () => <h3>Welcome to the About Page</h3> | |
const NotFound = () => <h1>404.. This page is not found!</h1> | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment