Skip to content

Commit 9be29a9

Browse files
author
Clauderic Demers
committed
Fix issues with removeEventListener when container is undefined
1 parent 55eefdc commit 9be29a9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/SortableContainer/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
134134
}
135135

136136
componentWillUnmount() {
137-
for (const key in this.events) {
138-
if (this.events.hasOwnProperty(key)) {
139-
events[key].forEach(eventName =>
140-
this.container.removeEventListener(eventName, this.events[key])
141-
);
137+
if (this.container) {
138+
for (const key in this.events) {
139+
if (this.events.hasOwnProperty(key)) {
140+
events[key].forEach(eventName =>
141+
this.container.removeEventListener(eventName, this.events[key])
142+
);
143+
}
142144
}
143145
}
144146
}

0 commit comments

Comments
 (0)