mirror of
https://github.com/jambonz/next-static-site.git
synced 2026-07-04 19:21:55 +00:00
Switch to modern event listener for window.matchMedia
This commit is contained in:
@@ -31,12 +31,12 @@ export function useMobileMedia() {
|
||||
useEffect(() => {
|
||||
const mql = window.matchMedia(mobileMedia);
|
||||
|
||||
mql.addListener(handleMedia);
|
||||
mql.addEventListener('change', handleMedia);
|
||||
|
||||
setMobile(mql.matches);
|
||||
|
||||
return function cleanup() {
|
||||
mql.removeListener(handleMedia);
|
||||
mql.removeEventListener('change', handleMedia);
|
||||
};
|
||||
}, [handleMedia, setMobile]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user