Skip to content

Commit f1f7569

Browse files
committed
Ensure event handlers are destroyed on unmount.
These can be left over if, for instance, the draggable item has a 'close' button which closes on mousedown.
1 parent 22e88aa commit f1f7569

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)