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 b3f7e40588
commit 99da4a112a

View file

@ -28,7 +28,7 @@ class UndoRedoComponent extends React.Component
clearTimeout(@_timeout) clearTimeout(@_timeout)
_setNewTimeout: => _setNewTimeout: =>
clearTimeout(@_timeout) @_clearTimeout()
@_timeout = setTimeout (=> @_timeout = setTimeout (=>
@_hide() @_hide()
return return
@ -43,10 +43,11 @@ class UndoRedoComponent extends React.Component
return {show: s, task: t} return {show: s, task: t}
componentWillMount: -> componentWillMount: ->
@unsub = UndoRedoStore.listen(@_onChange) @_unsubscribe = UndoRedoStore.listen(@_onChange)
componentWillUnmount: -> componentWillUnmount: ->
@unsub() @_clearTimeout()
@_unsubscribe()
render: => render: =>
items = [].concat(@_renderUndoRedoManager()) items = [].concat(@_renderUndoRedoManager())