Skip to content

Instantly share code, notes, and snippets.

@ioness
Created February 24, 2018 06:25
Show Gist options
  • Save ioness/21df1596a18e0bf25c728272d6066402 to your computer and use it in GitHub Desktop.
Save ioness/21df1596a18e0bf25c728272d6066402 to your computer and use it in GitHub Desktop.
// App component
router() {
let path = location.pathname.split('/')[1] || '/'
switch(path) {
case '/': return <Page />
case 'barcelona': return <Page />
case 'madrid': return <Page />
case 'activities': return <Page />
case 'trips': return <Page />
default: return <NotFound />
}
}
render () {
return (<div>{this.router()}</div>)
}
// Page component
router() {
let path = location.pathname.split('/')[1] || '/'
switch(path) {
case '/': return <Home />
case 'trips': return <Trips />
case 'activities': return <Activities />
}
path = location.pathname.split('/')[2] || '/'
switch(path) {
case '/': return <Home />
case 'trips': return <Trips />
case 'activities': return <Activities />
default: return <NotFound />
}
}
render() {
return (
<div>
<Status status={this.props.status}/>
<Header />
{this.router()}
<Footer />
</div>
)
}
// Trips component
router() {
if(location.pathname.split('/')[3]) {
return <Trip />
}
let path = location.pathname.split('/')[2] || '/'
switch(path) {
case '/': return <div>Trip list</div>
case 'trips': return <div>Trip list</div>
default: return <Trip />
}
}
render() {
return this.router()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment