mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-08 01:04:39 +08:00
fix(undo-redo): Clear timeout when component unmounts to avoid React errors
This commit is contained in:
parent
e050c198d9
commit
1959790183
1 changed files with 4 additions and 3 deletions
|
@ -28,7 +28,7 @@ class UndoRedoComponent extends React.Component
|
|||
clearTimeout(@_timeout)
|
||||
|
||||
_setNewTimeout: =>
|
||||
clearTimeout(@_timeout)
|
||||
@_clearTimeout()
|
||||
@_timeout = setTimeout (=>
|
||||
@_hide()
|
||||
return
|
||||
|
@ -43,10 +43,11 @@ class UndoRedoComponent extends React.Component
|
|||
return {show: s, task: t}
|
||||
|
||||
componentWillMount: ->
|
||||
@unsub = UndoRedoStore.listen(@_onChange)
|
||||
@_unsubscribe = UndoRedoStore.listen(@_onChange)
|
||||
|
||||
componentWillUnmount: ->
|
||||
@unsub()
|
||||
@_clearTimeout()
|
||||
@_unsubscribe()
|
||||
|
||||
render: =>
|
||||
items = [].concat(@_renderUndoRedoManager())
|
||||
|
|
Loading…
Reference in a new issue