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

Commit

Permalink
feat(addons/RoutingWrapper): remove mentions about lazy
Browse files Browse the repository at this point in the history
feat(addons/RoutingWrapper): remove mentions about `lazy`
  • Loading branch information
Metnew committed Nov 3, 2017
1 parent 01bf70e commit 2dcaa6e
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/common/components/addons/RoutingWrapper/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import React, {Component} from 'react'
import {Switch, Redirect} from 'react-router-dom'
import LazyLoad from 'components/addons/LazyLoad'
import {getAuthState} from 'selectors'
import type {RouteItem} from 'types'

Expand Down Expand Up @@ -44,30 +43,19 @@ export default class RoutingWrapper extends Component {
render () {
const {routes} = this.props
const onlyRoutes = routes.filter(
a => a.tag || a.component || a.lazy || !a.external
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" `protected route` or "Route"?
// is it "RouteAuth" (e.g. `protected route`) or "Route"?
const Tag = a.tag
const {path, exact, strict, component, lazy} = a
// can visitor access this route?
// this function determinates is user allowed to visit route
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 = {path, exact, strict, canAccess}
// Select only props that we need
const b = {canAccess, path, exact, strict, component}

if (lazy) {
const routeToRenderLazy = (
<Tag {...b} key={i}>
<LazyLoad component={component} />
</Tag>
)
return routeToRenderLazy
}

// it can be Route or RouteAuth
return <Tag key={i} {...b} component={component} />
})

Expand Down

0 comments on commit 2dcaa6e

Please sign in to comment.