fix(undo-redo): Clear timeout when component unmounts to avoid React errors

This commit is contained in:
Ben Gotow 2015-08-03 10:21:04 -07:00
parent e050c198d9
commit 1959790183

View file

@ -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())