diff --git a/packages/slate-react/src/components/editor.js b/packages/slate-react/src/components/editor.js index cb111ae4f..6edadb53d 100644 --- a/packages/slate-react/src/components/editor.js +++ b/packages/slate-react/src/components/editor.js @@ -157,6 +157,17 @@ class Editor extends React.Component { this.flushChange() } + /** + * When the component unmounts, clear flushTimeout if it has been set + * to avoid calling onChange after unmount. + */ + + componentWillUnmount = () => { + if (this.tmp.flushTimeout) { + clearTimeout(this.tmp.flushTimeout) + } + } + /** * Queue a `change` object, to be able to flush it later. This is required for * when a change needs to be applied to the value, but because of the React