Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './polyfills/mediaQueryList'

import * as Sentry from '@sentry/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
Expand Down
25 changes: 25 additions & 0 deletions src/polyfills/mediaQueryList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Polyfill for the deprecated MediaQueryList.addListener/removeListener APIs.
*
* Some third-party libraries (e.g. react-hot-toast v2.4.1) still use the
* deprecated addListener/removeListener methods on MediaQueryList. Modern
* browsers are removing these in favour of addEventListener/removeEventListener.
* This polyfill restores them so those libraries continue to work.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener
*/
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
const mql = window.matchMedia('')
if (mql && typeof mql.addListener === 'undefined') {
MediaQueryList.prototype.addListener = function (

Check failure on line 14 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Helmtest

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 14 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Run Type Checker

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 14 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Staging

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 14 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Production

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 14 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Build App

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.
handler: Parameters<MediaQueryList['addEventListener']>[1]
) {
this.addEventListener('change', handler)
}
MediaQueryList.prototype.removeListener = function (

Check failure on line 19 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Helmtest

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 19 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Run Type Checker

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 19 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Staging

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 19 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Production

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.

Check failure on line 19 in src/polyfills/mediaQueryList.ts

View workflow job for this annotation

GitHub Actions / Build App

Type '(handler: EventListenerOrEventListenerObject) => void' is not assignable to type '(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null) => void'.
handler: Parameters<MediaQueryList['removeEventListener']>[1]
) {
this.removeEventListener('change', handler)
}
}
}
Loading