Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
fix(components): fix rendering of Redirects in RoutingWrapper
Browse files Browse the repository at this point in the history
fix(components): fix rendering of Redirects in RoutingWrapper
  • Loading branch information
Metnew committed Dec 5, 2017
1 parent d84d865 commit 4b72701
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/common/components/addons/RoutingWrapper/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {connect} from 'react-redux'
import {withRouter} from 'react-router'
import {Switch} from 'react-router-dom'
import {getAuthState} from 'selectors'
import _ from 'lodash'
import type {RouteItem} from 'types'

type Props = {
Expand All @@ -19,11 +20,13 @@ const RoutingWrapper = (props: Props) => {
const routesRendered = routesToRender.map((a: RouteItem, i) => {
// Get tag for Route.
const Tag = a.tag
const {component, path, exact, strict} = a
const b = {component, path, exact, strict}
return <Tag key={i} {...b} />
return (
<Tag
key={i}
{..._.pick(a, 'component', 'path', 'exact', 'strict', 'to')}
/>
)
})
console.log(routesRendered)

return <Switch>{routesRendered}</Switch>
}
Expand All @@ -33,10 +36,10 @@ function mapStateToProps (state, props) {
const {isLoggedIn} = getAuthState(state)

/**
* Checks Auth logic. Is user allowed to visit certain path?
* @param {String} path next path to visit
* @return {Bool} is user allowed to visit next location?
*/
* Checks Auth logic. Is user allowed to visit certain path?
* @param {String} path next path to visit
* @return {Bool} is user allowed to visit next location?
*/
const authCheck = ({path}): boolean => {
const authPath = '/auth'
const allowedToVisitPath = [authPath]
Expand All @@ -59,10 +62,4 @@ function mapStateToProps (state, props) {
}
}

function mapDispatchToProps () {
return {}
}

export default connect(mapStateToProps, mapDispatchToProps)(
withRouter(RoutingWrapper)
)
export default connect(mapStateToProps)(withRouter(RoutingWrapper))

0 comments on commit 4b72701

Please sign in to comment.