我正在尝试将 Unlayer 包含在我的 React 应用程序中,如下所示:https://github.com/unlayer/react-email-editor 。我为此使用 Webpack。
但是,一旦我将 EmailEditor 导入我的模块之一:
import React from 'react';
import EmailEditor from 'react-email-editor';
我收到错误:
Uncaught TypeError: Object(...) is not a function
at Object.<anonymous>
我的环境:
"dependencies": {
"prop-types": "^15.6.0",
"react": "^16.0.0",
"react-email-editor": "^0.9.0",
"react-load-script": "0.0.6",
"styled-components": "^4.1.2"
}
知道什么可能导致这种错误的导入/导出吗?
最佳答案
最新版本的 styled-component
在 React 版本 16.0.0 中中断,因为它依赖于新的上下文 API。 React v16.3.0
中引入了新的上下文 API。
要解决此问题,您可以尝试以下操作之一。
使用任何 React 版本 >= 16.3.0。
使用旧版本的
styled-component
,它不需要新的 React context API。 styled-component v4.0.0 中引入了新的上下文 API
查看使用react v16.0.0
的损坏版本。 https://codesandbox.io/s/9l25580ppy
查看使用最新React版本的工作版本v16.6.3
https://codesandbox.io/s/6lrv8zoj6r
查看使用旧版本样式组件的工作版本v3.4.10
https://codesandbox.io/s/xvo2658j7w
关于javascript - Unlayer EmailEditor 导入 React 会破坏应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53651808/