Last active
October 11, 2019 10:00
-
-
Save udittyagi/eb91152ba5f8d0d2cd5c766581f0cd34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleQueryListener = () => { | |
const updatedMatches = keys.reduce((acc, media) => { | |
acc[media] = !!(mediaQueryLists[media] && mediaQueryLists[media].matches); | |
return acc; | |
}, {}) | |
console.log('Matches', updatedMatches) | |
} | |
keys.forEach(media => { | |
if(typeof queries[media] === 'string') { | |
mediaQueryLists[media].addListener(handleQueryListener) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment