Remove GroupStore listener when unmounting GroupPublicityToggle

This commit is contained in:
Luke Barnard 2018-05-01 11:50:14 +01:00
parent 28e8ce967f
commit 38d7a5d394

View file

@ -40,7 +40,7 @@ export default React.createClass({
},
_initGroupStore: function(groupId) {
GroupStore.registerListener(groupId, () => {
this._groupStoreToken = GroupStore.registerListener(groupId, () => {
this.setState({
isGroupPublicised: GroupStore.getGroupPublicity(groupId),
ready: GroupStore.isStateReady(groupId, GroupStore.STATE_KEY.Summary),
@ -48,6 +48,10 @@ export default React.createClass({
});
},
componentWillUnmount() {
if (this._groupStoreToken) this._groupStoreToken.unregister();
},
_onPublicityToggle: function(e) {
e.stopPropagation();
this.setState({