🐛 Corrige un bug critique sur les anciennes versions de Safari

Tentative de correction basée sur le rapport Sentry, mais non testée.
Voir #1790.
pull/1793/head
Maxime Quandalle 2021-10-19 11:24:31 +02:00
parent cd9192e660
commit 31cdb29fc2
1 changed files with 4 additions and 2 deletions

View File

@ -12,9 +12,11 @@ const useIsPrintContext = () => {
const matchMediaPrint = window.matchMedia('print')
setPrintContext(matchMediaPrint.matches)
matchMediaPrint.addEventListener('change', matchListener)
// `addEventListener` isn't supported by old versions of Safari and throws a
// fatal error. See #1790 and https://stackoverflow.com/a/56466334
matchMediaPrint?.addEventListener('change', matchListener)
return () => {
matchMediaPrint.removeEventListener('change', matchListener)
matchMediaPrint?.removeEventListener('change', matchListener)
}
}, [])