Skip to content

Commit

Permalink
Merge pull request #18 from vavdav/bugfix-removelistener
Browse files Browse the repository at this point in the history
There is possible memory leak and bug leads to many listeners. It is …
  • Loading branch information
contra committed Aug 13, 2015
2 parents 7eeaad5 + d435265 commit e07b880
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ var mq = React.createClass({
}, {});
}

if (this._mql) {
this._mql.removeListener(this.updateMatches);
}

this._mql = matchMedia(this.query, values);
this._mql.addListener(this.updateMatches);
this.updateMatches();
Expand Down

0 comments on commit e07b880

Please sign in to comment.