Skip to content

Commit

Permalink
Merge pull request #376 from clauderic/fix-remove-listener-bug
Browse files Browse the repository at this point in the history
Fix issues with removeEventListener when container is undefined
  • Loading branch information
Claudéric Demers committed May 18, 2018
2 parents 0716d75 + 9be29a9 commit de05b98
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/SortableContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
}

componentWillUnmount() {
for (const key in this.events) {
if (this.events.hasOwnProperty(key)) {
events[key].forEach(eventName =>
this.container.removeEventListener(eventName, this.events[key])
);
if (this.container) {
for (const key in this.events) {
if (this.events.hasOwnProperty(key)) {
events[key].forEach(eventName =>
this.container.removeEventListener(eventName, this.events[key])
);
}
}
}
}
Expand Down

0 comments on commit de05b98

Please sign in to comment.