diff --git a/index.js b/index.js index 63db34e..c7153ae 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/package.json b/package.json index 00bac8e..36a1bc6 100644 --- a/package.json +++ b/package.json @@ -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",