[Solved] new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method

Problem: Got these error while working on react native project -
new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method
Solution 1:
This is possible due to the newest version of react-native. A lot of libraries still haven't released a new version to handle these errors (or warnings in some cases). Examples include https://github.com/react-navigation/react-navigation/issues/9882 and https://github.com/APSL/react-native-keyboard-aware-scroll-view/pull/501. If it bothers us, we can hide the warning for now (source):
import { LogBox } from 'react-native';
LogBox.ignoreLogs(['new NativeEventEmitter']); // Ignore log notification by message
LogBox.ignoreAllLogs(); //Ignore all log notifications
Solution 2:
We just add two functions to main java module:
// Required for rn built in EventEmitter Calls.
@ReactMethod
public void addListener(String eventName) {
}
@ReactMethod
public void removeListeners(Integer count) {
}
Example: for fix warning in react-native-fs
add functions to android/src/main/java/com/rnfs/RNFSManager.java
file.
Solution 3:
It is the issue related to react native reanimated library. We solve it by uninstalling the library and reinstalling it. Remove all the installation steps of the react-native-reanimated library provided by https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation.
Simply install the library using command npm install react-native-reanimated@2.3.0-beta.1
If the issue is still then open project in android studio. Go to file->invalidate cache. After it, all things work perfectly.
Thank you for reading the article.