如何通过传入的路由参数将react-loadable应用于路由器

时间:2018-11-01 02:54:24

标签: reactjs react-loadable

我想通过基于路由拆分代码来优化代码。我发现有几个软件包可以执行此操作,但是路由器是一组嵌套的路由器组件,例如

<Router>
  <Switch>
    <Route exact path="/" component={Home}/>
    <Route path="/about" component={About}/>
  </Switch>
</Router>

但是,在我的代码中,它是由一个路由对象配置的,因此就像:

<Router history={history} routes={routes} />

路线就像

routes = [{
 path: '/',
 component: Root,
 childRoutes: [
  { indexRoute: { onEnter: (nextState, replace) => replace('/settings') } },
  { path: '/settings/', component: Settings },
],

}];

如何将Loadable应用于路由配置对象?

0 个答案:

没有答案