Skip to content
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

fix: EventEmitter warnings #1615

Merged
merged 4 commits into from
Nov 19, 2021
Merged

fix: EventEmitter warnings #1615

merged 4 commits into from
Nov 19, 2021

Conversation

ferdicus
Copy link
Member

@ferdicus ferdicus commented Nov 3, 2021

Description

Native EventEmitters api seems to have slightly changed.
They expect a addListener removeListener method on the native modules.

Would be showing warning messages like these:
'new NativeEventEmitter() was called with a non-null argument without the required addListener method.'

See: facebook/react-native@114be1d


Additionally, EventEmitter.js itself does change removeListener => just remove, which is called on the return value of addListener.
I've changed the code accordingly.

Would be showing warning messages like these:
EventEmitter.removeListener(): Method has been deprecated. Please instead use remove() on the subscription returned by EventEmitter.addListener.

What I didn't do where extensive test on those components/ files.
I've did some simple playing around within the example app - would appreciate some full fledged tests with this PR though

Fixes #1594

Checklist

  • I have tested this on a device/simulator for each compatible OS
  • I formatted JS and TS files with yarn lint
  • I mentioned this change in CHANGELOG.md

@ferdicus ferdicus self-assigned this Nov 3, 2021
@ferdicus ferdicus mentioned this pull request Nov 3, 2021
@lisabaut
Copy link
Contributor

lisabaut commented Nov 4, 2021

@ferdicus
Copy link
Member Author

ferdicus commented Nov 5, 2021

Hi Ferdi, I assume the mock needs to be changed too: https://github.com/react-native-mapbox-gl/maps/blob/master/__tests__/__mocks__/react-native.mock.js#L8

you are correct - thank you 👍🏿

@ferdicus ferdicus merged commit f536886 into master Nov 19, 2021
@ferdicus ferdicus deleted the fix/event-emitter branch November 19, 2021 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warnings with RN 0.66.1
2 participants