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

Commit

Permalink
fix(routing): fix detection of routerRoutes
Browse files Browse the repository at this point in the history
fix(routing): fix detection of routerRoute
  • Loading branch information
Metnew committed Nov 3, 2017
1 parent 862d8c4 commit f1224b9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/common/routing/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React from 'react'
import {Route} from 'react-router-dom'
import {Route, Redirect} from 'react-router-dom'
import RouteAuth from 'components/addons/RouteAuth'
import {asyncComponent} from 'react-async-component'
import {Loader, Dimmer, Header, Icon} from 'semantic-ui-react'
Expand All @@ -11,11 +11,10 @@ function asyncComponentCreator (url) {
const importCreator = (url: string) => async () => {
// Read Webpack docs about code-splitting for more info.
if (process.env.BROWSER) {
const resolve = import(/* webpackMode: "lazy", webpackChunkName: "[request].lazy" */ `containers/${url}/index.jsx`)
return resolve
// const resolve = import(/* webpackMode: "lazy", webpackChunkName: "[request].lazy" */ `containers/${url}/index.jsx`)
return import(/* webpackMode: "lazy", webpackChunkName: "[request].lazy" */ `containers/${url}/index.jsx`)
}
const resolve = import(/* webpackMode: "eager" */ `containers/${url}/index.jsx`)
return resolve
return import(/* webpackMode: "eager" */ `containers/${url}/index.jsx`)
}

return asyncComponent({
Expand Down Expand Up @@ -79,13 +78,17 @@ function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
exact: true,
tag: Route,
component: asyncComponentCreator('Login')
}
},
// find the way to add/remove routes conditionally
// {
// name: '404',
// tag: RouteAuth,
// component: asyncComponentCreator('NotFound')
// }
{
name: '404',
tag: RouteAuth,
component: asyncComponentCreator('NotFound')
},
{
tag: Redirect,
to: '/auth'
}
]

const fns = {
Expand All @@ -100,7 +103,7 @@ function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
// Returns routing for React-Router
routing (x: Array<RouteItem> = routes) {
return x
.filter(a => !a.sidebarVisible)
.filter(a => !!a.tag)
.map(a => _.pick(a, ['path', 'name', 'strict', 'exact', 'component', 'tag']))
},
all () {
Expand Down

0 comments on commit f1224b9

Please sign in to comment.