Skip to content

Commit

Permalink
There is possible memory leak and bug leads to many listeners. It is …
Browse files Browse the repository at this point in the history
…neccessary to remove listener before creating new object.
  • Loading branch information
David Vavrousek committed Aug 13, 2015
1 parent 7eeaad5 commit 441f713
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 441f713

Please sign in to comment.