我想使用Facebook的draftjs组件,但我遇到了一些障碍。
import React from 'react';
import ReactDOM from 'react-dom';
import { Editor, EditorState } from 'draft-js';
class MyEditor extends React.Component{
constructor(props) {
super(props);
this.state = {
editorState: EditorState.createEmpty()
};
this.onChange = (editorState) => this.setState({ editorState });
}
render(){
var {editorState} = this.state;
return(
<Editor editorState={ editorState } onChange={ this.onChange } />
);
}
}
ReactDOM.render(
<MyEditor />,
document.getElementById('container')
);
这是我写的代码,但是=&gt;
Warning: A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.
console.error(message);
我按如下方式更改了代码,并成功了=&gt;
render(){
var {editorState} = this.state;
return(
<div>富文本编辑器</div>
);
}
但这就是为什么?