Skip to content

deprecated addListener and removeListener update #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2019
Merged

deprecated addListener and removeListener update #135

merged 1 commit into from
Aug 16, 2019

Conversation

Maxim-Mazurok
Copy link
Contributor

addListener and removeListener are deprecated in a favor of addEventListener and removeEventListener.

From MediaQueryList/addListener

This (addListener) is basically an alias for EventTarget.addEventListener(), for backwards compatibility purposes.

They are supported by all major browsers: EventTarget/addEventListener

BTW, TSLint is producing the following error when trying to use addListener:

ERROR: /app/Component.tsx:xx:xx - addListener is deprecated.

@edorivai edorivai merged commit 68475ea into ReactTraining:master Aug 16, 2019
@edorivai
Copy link
Collaborator

Thanks @Maxim-Mazurok!

@Maxim-Mazurok
Copy link
Contributor Author

So, I just found out that it's not supported in Safari on Mac OS. I tried 13.0 and 13.1 (TP).
Both of them only know addListener for MediaQueryList, unfortunately.
It's not working on my iOS devices also (iOS 12.4).
You might want to revert this change or make it part of the major release, introducing a breaking change. Sorry about that...

@edorivai
Copy link
Collaborator

Well that's weird, I glanced over the browser compatibility source you shared and it looked pretty good. Thanks for the heads up, at least I hadn't published to npm yet 😁

@Maxim-Mazurok
Copy link
Contributor Author

Maxim-Mazurok commented Aug 21, 2019

Yeah, they support addEventListener in general, but not for the MediaQueryList, unfortunately.
Here's a relevant issue: microsoft/TypeScript#32210

BTW, the best way to see the browser support for these particular methods is to go to MDN:MediaQueryList#Browser_compatibility and check out MediaQueryList inheriting from EventTarget section of the table. Thanks to mdn/browser-compat-data#3674 for making this contribution.

@edorivai
Copy link
Collaborator

Reverted, thanks again for the heads up 🙏

@Maxim-Mazurok
Copy link
Contributor Author

Good news for Safari: addEventListener was added for MediaQueryList in Safari 14.0 TP (Release 109 (Safari 14.0, WebKit 15610.1.17.2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants