我有一个使用React Router的React应用程序。我的旧路线看起来像这样:
const ComponentRoutes = (
<Route path='/' component={App}>
<IndexRoute component={LandingPage} />
<Route path='/dashboard' component={RequireAuth(Dashboard)} />
</Route>
);
RequireAuth是一个HOC,只允许用户在拥有正确凭据的情况下转到Dashboard。
现在我正在使用Webpack 2,我不得不重构我的路线:
const componentRoutes = {
component: App,
path: '/',
indexRoute: { component: LandingPage },
childRoutes: [
{
path: 'dashboard',
getComponent(location, cb) {
System.import('./components/dashboard')
.then(module => cb(null, module.default));
}
}
]
};
如何将RequireAuth HOC添加回路线?