我正在尝试导入一个反应组件,@babel/plugin-syntax-dynamic-import
但我无法使其工作。
这是我的主要组件中的代码:
import React from 'react';
import Loadable from 'react-loadable';
const Test = Loadable({
loader: () => import('./Space').default,
loading: <div>loading</div>
});
const App = () => <Test />;
export default App;
我的空间组件中的代码:
import React from 'react';
const Space = () => <h1>hello from space</h1>;
export default Space;
使用此代码,我收到此错误:Uncaught TypeError: Cannot read property 'then' of undefined
我把它放在这里而不知道它是否有帮助:The above error occurred in the <LoadableComponent> component: react-dom.development.js:17117
是的,我已经@babel/plugin-syntax-dynamic-import
安装并添加到我的 babel 配置文件中。