diff --git a/CHANGELOG.md b/CHANGELOG.md index fec7602..812eff3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.2.1 +* Fix a potential bug in connect/StoreDependencyMixin that could cause an exeption in `componentWillUnmount` + ## 2.2.0 * Component generated by `connect` inherits propTypes unrelated to the store dependencies from the BaseComponent diff --git a/bower.json b/bower.json index e7f04df..6b7eb43 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "general-store", - "version": "2.2.0", + "version": "2.2.1", "homepage": "https://github.com/HubSpot/general-store", "authors": [ "Colby Rabideau " diff --git a/package.json b/package.json index 837a321..4ee8089 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "general-store", - "version": "2.2.0", + "version": "2.2.1", "description": "Simple, flexible store implementation for Flux.", "main": "lib/GeneralStore.js", "scripts": { diff --git a/src/dependencies/StoreDependencyMixin.js b/src/dependencies/StoreDependencyMixin.js index c2e6657..8b70e49 100644 --- a/src/dependencies/StoreDependencyMixin.js +++ b/src/dependencies/StoreDependencyMixin.js @@ -78,8 +78,10 @@ export default function StoreDependencyMixin( }, componentWillUnmount(): void { - if (dispatcher && this.__dispatchToken) { - dispatcher.unregister(this.__dispatchToken); + const dispatchToken = this.__dispatchToken; + if (dispatcher && dispatchToken) { + this.__dispatchToken = null; + dispatcher.unregister(dispatchToken); } }, diff --git a/src/dependencies/connect.js b/src/dependencies/connect.js index 80d2976..e784d53 100644 --- a/src/dependencies/connect.js +++ b/src/dependencies/connect.js @@ -65,8 +65,10 @@ export default function connect( } componentWillUnmount(): void { - if (dispatcher && this.dispatchToken) { - dispatcher.unregister(this.dispatchToken); + const dispatchToken = this.dispatchToken; + if (dispatcher && dispatchToken) { + this.dispatchToken = null; + dispatcher.unregister(dispatchToken); } }