Skip to content

Commit

Permalink
switch to matchmedia module for client/server abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Feb 27, 2015
1 parent 72f4e25 commit 759154b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
],
"dependencies": {
"lodash.omit": "^3.0.0",
"matchmedia": "^0.1.1",
"object-assign": "^2.0.0"
},
"peerDependencies": {
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ var React = require('react');
var omit = require('lodash.omit');
var mediaQuery = require('./mediaQuery');
var toQuery = require('./toQuery');
var matchMedia = typeof window !== 'undefined' ? window.matchMedia : null;
var matchMedia = require('matchmedia');

var defaultTypes = {
component: React.PropTypes.func,
query: React.PropTypes.string
query: React.PropTypes.string,
values: React.PropTypes.object
};
var mediaKeys = Object.keys(mediaQuery.all);
var excludedQueryKeys = Object.keys(defaultTypes);
Expand Down Expand Up @@ -49,7 +50,7 @@ var mq = React.createClass({
if (!this.query) {
throw new Error('Invalid or missing MediaQuery!');
}
this._mql = matchMedia(this.query);
this._mql = matchMedia(this.query, this.props.values);
this._mql.addListener(this.updateMatches);
this.updateMatches();
},
Expand Down

0 comments on commit 759154b

Please sign in to comment.