mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-26 08:34:28 +02:00
fix calling onChange handler after Editor component unmount (#1399)
This commit is contained in:
committed by
Ian Storm Taylor
parent
267800c26f
commit
038de22b43
@@ -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
|
||||
|
Reference in New Issue
Block a user