diff --git a/src/hooks/useMatchBreakpoints.ts b/src/hooks/useMatchBreakpoints.ts index 8da4a35b7..8947a9bb2 100644 --- a/src/hooks/useMatchBreakpoints.ts +++ b/src/hooks/useMatchBreakpoints.ts @@ -58,10 +58,16 @@ const useMatchBreakpoints = (): State => { })); }; - mql.addEventListener("change", handler); + // Safari < 14 fix + if (mql.addEventListener) { + mql.addEventListener("change", handler); + } return () => { - mql.removeEventListener("change", handler); + // Safari < 14 fix + if (mql.removeEventListener) { + mql.removeEventListener("change", handler); + } }; });