r/javascript • u/[deleted] • Aug 21 '18
Effectively supported in all browsers, JavaScript has its own form of media queries just like CSS.
https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
465
Upvotes
r/javascript • u/[deleted] • Aug 21 '18
2
u/atubofsoup Aug 24 '18
Just learned about this in one of my last projects and wrote a react HoC that takes a breakpoints object, adds listeners, re-renders when breakpoints change, and passes the active breakpoints to the wrapped component: