Skip to content

Commit

Permalink
SSR support
Browse files Browse the repository at this point in the history
  • Loading branch information
egdbear committed Oct 6, 2019
1 parent b6efa09 commit 175607d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useState, useEffect } from 'react';
import mediaQueries from './mediaQueries';

export default (query) => {
if (typeof window !== 'object') return; // SSR
if (typeof window !== 'object') return;
if (!window.matchMedia) return;

const queryToMatch = mediaQueries[query] || query;
const [matches, setMatches] = useState(window.matchMedia(queryToMatch).matches);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-simple-matchmedia",
"version": "3.0.0",
"version": "3.0.2",
"description": "React component used for matching media queries",
"main": "build/index.cjs.js",
"module": "build/index.es.js",
Expand Down

0 comments on commit 175607d

Please sign in to comment.