Skip to content

Commit

Permalink
Fixed the freakin' router issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vkolova committed Sep 21, 2017
1 parent 29126dc commit e1937d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class App extends Component {
}
/>
<Route exact path='/sign-up' component={AuthLayout}></Route>
<Route exact path='/tv' component={MainLayout}></Route>
<Route exact path='/popular' component={MainLayout}></Route>
<Route exact path='/tv/search' component={MainLayout}></Route>
<Route exact path='/top-rated' component={MainLayout}></Route>
<Route exact path='/tv/:id' component={MainLayout}></Route>
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/layouts/MainLayout.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Route, Switch } from 'react-router-dom'
import { Route, Switch, withRouter } from 'react-router-dom'

import Sidebar from '~~/components/shared/Sidebar'
import Player from '~~/components/shared/Player'
Expand All @@ -24,9 +24,9 @@ const MainLayout = props => (
<Sidebar store={UserStore}/>
<Switch>
<Route exact path='/' component={Home}></Route>
<Route exact path='/tv' component={Popular}></Route>
<Route exact path='/popular' component={withRouter(Popular)}></Route>
<Route exact path='/tv/search' component={Search}></Route>
<Route exact path='/top-rated' component={TopRated}></Route>
<Route exact path='/top-rated' component={withRouter(TopRated)}></Route>
<Route exact path='/tv/:id' component={Show}></Route>
<Route exact path='/u/:username' component={UserProfile}></Route>
<Route exact path='/player' component={Player}></Route>
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/shared/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { NavLink } from 'react-router-dom'
import { NavLink, withRouter } from 'react-router-dom'
import { observer } from 'mobx-react'

import Icon from '../shared/Icon'
Expand Down Expand Up @@ -70,7 +70,7 @@ const Sidebar = observer(props => (

<NavLink
exact
to='/top-rated?page=1'
to='/top-rated'
className='sb-link'
activeClassName='sb-link-active'
>
Expand All @@ -79,7 +79,7 @@ const Sidebar = observer(props => (

<NavLink
exact
to='/tv'
to='/popular'
className='sb-link'
activeClassName='sb-link-active'
>
Expand Down Expand Up @@ -121,4 +121,4 @@ const Sidebar = observer(props => (
</div>
))

export default Sidebar
export default withRouter(Sidebar)
6 changes: 3 additions & 3 deletions client/src/components/views/Popular.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React, { Component } from 'react'
import { Link } from 'react-router-dom'
import queryString from 'query-string'

Expand Down Expand Up @@ -40,12 +40,12 @@ export default class Popular extends Component {
<div className='pagination'>
{
this.state.data.page > 1
? <Link onClick={() => window.location.reload()} to={`/tv?page=${this.state.data.page * 1 - 1}`}>
? <Link to={`/popular?page=${this.state.data.page * 1 - 1}`}>
<Icon icon='chevron-left'/>
</Link>
: null
}
<Link onClick={() => window.location.reload()} to={`/tv?page=${this.state.data.page * 1 + 1}`}>
<Link to={`/popular?page=${this.state.data.page * 1 + 1}`}>
<Icon icon='chevron-right'/>
</Link>
</div>
Expand Down

0 comments on commit e1937d5

Please sign in to comment.