index.js 644 Bytes
Newer Older
zhanghaozhe committed
1
import React from 'react'
zhanghaozhe committed
2
import { Switch, Route } from 'react-router-dom'
zhanghaozhe committed
3
import RouterConfig from './router-config'
4
import PrivateRoute from './privateRoute'
zhanghaozhe committed
5 6

export default function () {
xuzhenghua committed
7 8 9 10 11 12 13
  return (
    <Switch>
      {RouterConfig.map((item, index) => {
        let {isPrivate, ...rest} = item
        if (isPrivate) {
          return <PrivateRoute {...rest} key={index}/>
        } else {
zhanghaozhe committed
14
          const {component: Component, ...rest} = item
xuzhenghua committed
15
          return (
zhanghaozhe committed
16 17 18
            <Route {...rest} key={index} render={(props) => {
              return <Component {...props}/>
            }}/>
xuzhenghua committed
19 20 21 22 23 24
          )
        }
      })}
    </Switch>
  )
}