react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

new NativeEventEmitter() was called with a non null argument without the required "addListener" method.

Open KiwipDev opened this issue 2 years ago • 1 comments

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

Screenshot

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.

KiwipDev avatar Sep 22 '22 08:09 KiwipDev

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.

moroshan avatar Sep 23 '22 07:09 moroshan

Hey, thanks for reporting the issue, I will investigate it!

michalchudziak avatar Sep 25 '22 09:09 michalchudziak

Until this is fixed, another option is to hide the warning 🙈

LogBox.ignoreLogs(['new NativeEventEmitter']);

t-fritsch avatar Sep 27 '22 21:09 t-fritsch

Is anyone resolved this warning? @t-fritsch @michalchudziak @moroshan @KiwipDev

BajajSaajan avatar Oct 07 '22 11:10 BajajSaajan

I'll look onto it this week

michalchudziak avatar Oct 10 '22 15:10 michalchudziak

@michalchudziak how do i get this changes at my current package.? Do i need to update this package or shall i do this manually?

BajajSaajan avatar Oct 11 '22 12:10 BajajSaajan

It's shipped in 3.0.2

michalchudziak avatar Oct 11 '22 13:10 michalchudziak