Add some comments

This commit is contained in:
Damien Duhamel 2017-07-25 10:28:35 +02:00
parent 4d2ed6b1ea
commit 1b3aec4ebf

View File

@ -135,8 +135,10 @@ export default class Editor extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const editorValue = this.state.serializer.serialize(this.view.state.doc); const editorValue = this.state.serializer.serialize(this.view.state.doc);
// Check that the content of the editor is well synchronized with the props value after rendering.
// Sometimes the editor isn't well updated (eg. after items reordering)
if (editorValue !== this.props.value && editorValue !== prevProps.value) { if (editorValue !== this.props.value && editorValue !== prevProps.value) {
// If the content of the editor isn't correct, we update its state with a new one.
this.view.updateState(this.createEditorState()); this.view.updateState(this.createEditorState());
} }
} }