我有一些使用动态导入的代码从如下所示的配置中加载React组件:
import {Observable} from 'rxjs';
我有一些代码想要从已解析的动态导入中获取组件
export const routes: AsyncRouteProps[] = [
{ heading: 'Home', path: RoutePath.Home, component: Home, exact: true },
{
heading: 'Assessments',
path: '/assessments',
component: asyncComponent({
loader: () => import('../containers/Assessments'),
Placeholder: () => <Loading />
}),
icon: Assessments,
linkType: LinkType.Top
},
是否有比使用static load() {
return loader().then((ResolvedComponent) => {
const keys = Object.keys(ResolvedComponent);
Component = ResolvedComponent.default || (keys.length && ResolvedComponent[keys[0]]) || ResolvedComponent;
});
}
来获取模块更好的方法?