react-native-geolocation
react-native-geolocation copied to clipboard
new NativeEventEmitter() was called with a non null argument without the required "addListener" method.
Environment
System: OS: macOS 12.0.1 CPU: (8) arm64 Apple M1 Memory: 303.86 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.7.0 - /var/folders/8v/fxtg8gf53hxg33c467mx5cym0000gn/T/yarn--1663834600779-0.8417465260153014/node Yarn: 1.22.19 - /var/folders/8v/fxtg8gf53hxg33c467mx5cym0000gn/T/yarn--1663834600779-0.8417465260153014/yarn npm: 8.17.0 - /opt/homebrew/bin/npm Watchman: 2022.08.15.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.1 => 0.70.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Platforms
both
Versions
- Android: 11
- iOS: 15
- react-native-geolocation: latest
- react-native: 0.70.1
- react: 18.1
Description
Hello! React native emits warnings at each startup about the NativeEventEmitter because it is missing two methods as shown in the screenshot above. These methods are explained on official react native documentation. Currently, addListener() and removeListeners() have to be added to the Native Module object before instantiating it as an Event Emitter.
Reproducible Demo
Add the library to the project and import it in any js file.
same error - temporary solution for fix need to open package @react-native-community/geolocation/js/nativeInterface.ts
- new NativeEventEmitter() - WARN
- @react-native-community/geolocation/js/nativeInterface.ts
- problem because in package nativeEventEmitter is null like bellow
- let nativeEventEmitter: NativeEventEmitter | null = null
- if change this line in line bellow warn was disappear
- let nativeEventEmitter: NativeEventEmitter = new NativeEventEmitter()
and change
let nativeEventEmitter: NativeEventEmitter | null = null;
to
let nativeEventEmitter: NativeEventEmitter | null = {};
or
let nativeEventEmitter: NativeEventEmitter | null = new NativeEventEmitter();
The error will disappear, but what this will lead I don't understand.
Hey, thanks for reporting the issue, I will investigate it!
Until this is fixed, another option is to hide the warning 🙈
LogBox.ignoreLogs(['new NativeEventEmitter']);
Is anyone resolved this warning? @t-fritsch @michalchudziak @moroshan @KiwipDev
I'll look onto it this week
@michalchudziak how do i get this changes at my current package.? Do i need to update this package or shall i do this manually?
It's shipped in 3.0.2