由于 Draft 使用不可变的数据结构,因此不必占用大量资源——比较引用就足够了:
onChange(newEditorState) {
const currentContent = this.state.editorState.getCurrentContent()
const newContent = newEditorState.getCurrentContent()
if (currentContent !== newContent) {
// Content has changed
}
}