RN 0.65.0 require some new listener methods on the Native Module when call the NativeEventEmitter. It shows the "new NativeEventEmmiter()..." warning.
See original GitHub issueDescription
A lot of libraries, including this one is showing a warning with the message: “new NativeEventEmitter() was called with a non-null argument without the required addListener/removeListeners
method.” Like the image below:
This warning is shown because of the commit 114be1d, which checks if the Native Module has the methods: addListener
and removeListeners
. These checks are necessary because of this commit f5502fb, which tries to use the Native Module to notify subscriptions on Android. So I think this issue is only related to Android and the 0.65.0 release.
Doing some tests in another libraries with the old architecture I was able to fix it adding those methods in the Native Module in Java:
@ReactMethod
public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}
@ReactMethod
public void removeListeners(Integer count) {
// Keep: Required for RN built in Event Emitter Calls.
}
I don’t know if this is the best method to handle this issue, but I think it’s don’t cause any trouble like was commented in this commit f5502fb.
Expected behavior
Do not show any warning in the console about the NativeEventEmitter.
Actual behavior & steps to reproduce
Just build react-native 0.65.0 with this library and execute the most basic example in the docs.
Snack or minimal code example
The first example in the docs: https://docs.swmansion.com/react-native-reanimated/docs/animations
Package versions
- React Native: 0.65.0
- React Native Reanimated: 2.3.0-alpha.2
- NodeJS: 14.17.3
- Xcode:
- Java & Gradle: 11.0.10 / 6.9
Affected platforms
- Android
- iOS
- Web
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:10 (4 by maintainers)
may I ask you how to add those two methods in the Native Module in Java?
Issue validator
The issue is valid!