Skip to content

Commit cc6b2f5

Browse files
committed
Merge pull request #4 from STRML/master
Ensure event handlers are destroyed on unmount.
2 parents 22e88aa + f1f7569 commit cc6b2f5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/draggable.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ module.exports = React.createClass({
224224
onStop: React.PropTypes.func
225225
},
226226

227+
componentWillUnmount: function() {
228+
// Remove any leftover event handlers
229+
removeEvent(window, 'mousemove', this.handleMouseMove);
230+
removeEvent(window, 'mouseup', this.handleMouseUp);
231+
},
232+
227233
getDefaultProps: function () {
228234
return {
229235
axis: 'both',

0 commit comments

Comments
 (0)