Skip to content

Commit

Permalink
[fixed] extra timeout check, prevent setState after unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Jan 12, 2016
1 parent 4b6abc7 commit 438e30a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"less": "^2.5.1",
"less-loader": "^2.2.0",
"marked": "^0.3.5",
"mocha": "^2.3.4",
"moment": "^2.10.6",
"mt-changelog": "^0.6.2",
"node-libs-browser": "^0.5.2",
Expand Down
7 changes: 4 additions & 3 deletions src/mixins/TimeoutMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ module.exports = {
setTimeout(key, cb, duration){
var timers = this._timers || (this._timers = Object.create(null));

if ( this._unmounted)
if (this._unmounted)
return

clearTimeout(timers[key])
timers[key] = window.setTimeout(cb, duration)
timers[key] = window.setTimeout(() => {
if (!this._unmounted) cb()
}, duration)
}

}
1 change: 0 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"$": true,
"sinon": true,
"expect": true,
"sinon": true,
"__REACT_VERSION__": true
},
"plugins": [
Expand Down

0 comments on commit 438e30a

Please sign in to comment.