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
26
u/elysgaard Aug 22 '18
Been using this in our React/Redux app for a while now and it's awesome being able to programatically change how components are rendered based on screen sizes.
We listen to the changes with
Then the responsiveState high-order-component has something similar to this
This means than we only have one listener to the media queries no matter how many components are using it at the same time.