From 9be29a98ac29c2231458798e4d094174301cd0bc Mon Sep 17 00:00:00 2001 From: Clauderic Demers Date: Fri, 18 May 2018 15:37:17 -0400 Subject: [PATCH] Fix issues with removeEventListener when container is undefined --- src/SortableContainer/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/SortableContainer/index.js b/src/SortableContainer/index.js index 3244b8fbc..f84741ed8 100644 --- a/src/SortableContainer/index.js +++ b/src/SortableContainer/index.js @@ -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]) + ); + } } } }