DEV Community

Discussion on: `useWindowSize` React Hook To Handle Responsiveness In JavaScript

Collapse
stfbauer profile image
Stefan Bauer

Hi,

I am just wondering why you use matchMedia instead of all these complex calculations? media queries in JavaScript too matchMedia

Thanks
Stefan

Collapse
3sanket3 profile image
Sanket Patel Author

First time heard about the matchMedia. Thanks for the input.

Just wondering, is there any way to react if screen resized?

Collapse
stfbauer profile image
Stefan Bauer

Of course, it has an event receiver for onChange.

developer.mozilla.org/en-US/docs/W...

Thread Thread
3sanket3 profile image
Sanket Patel Author • Edited on

that's cool!