我正在使用React版本15.1.0。我想使用https://github.com/brijeshb42/medium-draft中的草稿编辑器。我正在尝试创建一个元素,但是我收到了一个错误。
var React = require('react')
var MediumDraftEditor = require('medium-draft');
var EmailTemplateContent = React.createClass({
render: function() {
return <MediumDraftEditor/>;
},
});
And, in some component I am calling this component
<EmailTemplateContent/>
我收到以下错误
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `EmailTemplateContent`.
http://127.0.0.1:8000/static/bundles/main-0a3cbca2a704a676c74d.js
Line 1127
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `EmailTemplateContent`.
答案 0 :(得分:1)
文档是用ES2015语法编写的。文档显示从“中草案”包中获取组件,如下所示:
import {
Editor,
createEditorState,
} from 'medium-draft';
ES5等价物将如下所示:
var Editor = require('medium-draft').Editor;
var createEditorState = require('medium-draft').createEditorState;