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

Commit

Permalink
feat(RoutingWrapper): use getRouterRoutes() instead of routes
Browse files Browse the repository at this point in the history
feat(RoutingWrapper): use `getRouterRoutes()` instead of routes
  • Loading branch information
Metnew committed Nov 3, 2017
1 parent 3c09b54 commit 64c4f30
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/common/components/addons/RoutingWrapper/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,22 @@ export default class RoutingWrapper extends Component {

render () {
const {routes} = this.props
const onlyRoutes = routes.filter(
a => a.tag || a.component || !a.external
)
// render components that are inside Switch (main view)
const routesRendered = onlyRoutes.map((a: RouteItem, i) => {
// get tag for Route.
// is it "RouteAuth" (e.g. `protected route`) or "Route"?
const routesRendered = routes.map((a: RouteItem, i) => {
// Get tag for Route.
// Is it "RouteAuth" (e.g. `protected route`) or "Route"?
const Tag = a.tag
const {path, exact, strict, component} = a
// Determinates is user allowed to visit certain route
const canAccess = this.authCheck.bind(this)
// Select only props that we need
const b = {canAccess, path, exact, strict, component}
const b = {canAccess, ...a}

return <Tag key={i} {...b} component={component} />
return <Tag key={i} {...b} />
})

return (
<Switch>
{routesRendered}
<Redirect to="/" />
</Switch>
)
}
Expand Down

0 comments on commit 64c4f30

Please sign in to comment.