Created
February 24, 2018 06:25
-
-
Save ioness/21df1596a18e0bf25c728272d6066402 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
// 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