【发布时间】:2022-08-03 22:37:55
【问题描述】:
我正在尝试动态导入模块但出现以下错误 -
编译有问题:X
./src/.../useCustomModule.js 21:21-56 中的警告
关键依赖:依赖的请求是一个表达式
import React from \"react\";
import PropTypes from \"prop-types\";
export const moduleMapping = {
CONTEXT_ONE: \"./....contextOnePath\",
CONTEXT_TWO: \"./....contextTwoPath\",
};
const getModule = (moduleName) => {
const module = React.lazy(() => import(moduleMapping[moduleName]));
return module;
};
export const useCustomModule = (moduleName) => {
return getModule(moduleName);
};
注意:在 eslintrc.json 我有以下设置 - \"ecmaVersion\": 12,
标签: javascript reactjs lazy-loading