Skip to content

Commit

Permalink
fix: Add fix for older versions of Safari (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
hachiojidev committed Jan 8, 2021
1 parent 51a95a6 commit 002fecc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hooks/useMatchBreakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
});

Expand Down

0 comments on commit 002fecc

Please sign in to comment.