Skip to content

Commit 6a14986

Browse files
committed
Merge pull request zillow#50 from dwhiffing/timeout-woes
Clear resize timeout on unmounting to prevent errors
2 parents e75d41e + c974f73 commit 6a14986

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

react-slider.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@
264264
},
265265

266266
componentWillUnmount: function () {
267+
clearTimeout(this.resizeTimeout)
267268
window.removeEventListener('resize', this._handleResize);
268269
},
269270

@@ -273,7 +274,7 @@
273274

274275
_handleResize: function () {
275276
// setTimeout of 0 gives element enough time to have assumed its new size if it is being resized
276-
window.setTimeout(function() {
277+
this.resizeTimeout = window.setTimeout(function() {
277278
var slider = this.refs.slider.getDOMNode();
278279
var handle = this.refs.handle0.getDOMNode();
279280
var rect = slider.getBoundingClientRect();

0 commit comments

Comments
 (0)