question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Description

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: image

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:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Radiant-Fcommented, Aug 20, 2021

may I ask you how to add those two methods in the Native Module in Java?

4reactions
github-actions[bot]commented, Aug 19, 2021

Issue validator

The issue is valid!

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - new NativeEventEmitter()` was called with a non-null ...
I just add two function to main java module: // Required for rn built in EventEmitter Calls.
Read more >
`new nativeeventemitter()` was called with a non-null ...
WARN `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method. It was working in the past on React Native...
Read more >
Source - GitHub
Android * **[Fix]** Fix `"new NativeEventEmitter()" was called with a non-null ... the required "some" method` warnings which appear with using react-native ......
Read more >
What does these two warnings mean? : r/reactnative - Reddit
`new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method. I moved my existing project to a new ...
Read more >
react-native v0.65.0 release notes | LibHunt
Bump Flipper + Bump hermes (#31872 by @Titozzz); Show warning when native module without addListener or removeListeners is passed to NativeEventEmitter ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found