Created
February 25, 2018 00:51
-
-
Save ioness/120eb4b0f08abbd063ec44449857fce9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.tsx | |
render () { | |
return <Page /> | |
} | |
// Page.tsx | |
router () { | |
let path = location.pathname.split('/')[1] || '/' | |
switch (path) { | |
case '/': return <Home /> | |
case 'trips': return <Trips /> | |
case 'activities': return <Activities /> | |
} | |
switch (path) { | |
case 'barcelona': break | |
case 'madrid': break | |
default: return <NotFound /> | |
} | |
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.tsx | |
router () { | |
let pathArray = location.pathname.split('/') | |
if(pathArray.length > 4 && pathArray[4]) return <NotFound /> | |
if (pathArray[3]) return <Trip /> | |
let path = pathArray[2] || '/' | |
let trips = this.props.trips.getIn(['entities', 'trips']) | |
let tripsIndexList = this.props.trips.getIn(['result', 'trips']) | |
switch (path) { | |
case '/': return <div><List items={trips} indexList={tripsIndexList} /></div> | |
case 'trips': return <div><List items={trips} indexList={tripsIndexList} /></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