1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-26 16:44:22 +02:00

fix calling onChange handler after Editor component unmount (#1399)

This commit is contained in:
danielsarin
2017-11-13 21:48:23 +02:00
committed by Ian Storm Taylor
parent 267800c26f
commit 038de22b43

View File

@@ -157,6 +157,17 @@ class Editor extends React.Component {
this.flushChange() 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 * 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 * when a change needs to be applied to the value, but because of the React