Skip to content

Commit 4880540

Browse files
committed
fix(useMediaQuery): add compatibility for addEventListener and addListener methods
1 parent 5cf93f2 commit 4880540

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/useMediaQuery/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ const createQueryEntry = (query: string) => {
1717
}
1818
};
1919

20-
mql.addEventListener('change', listener, {passive: true});
20+
if (mql.addEventListener) {
21+
mql.addEventListener('change', listener, {passive: true});
22+
} else {
23+
mql.addListener(listener);
24+
}
2125

2226
return {
2327
mql,

0 commit comments

Comments
 (0)