-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new NativeEventEmitter()
was called with a non-null argument without the required addListener
method.
#137
Comments
Same issue here |
I have this message before but I don't see it again after I change my code to ` export const listenLocationChange = async (SystemSetting, dispatch) => { // Components.js I hope you already solve your problem |
I worked on this recently and had similar issue. Here's the same comment as above with proper indentation and syntax highlighting. // utils.js
import { locationAction } from '../slices/locationSlice';
export const listenLocationChange = async (SystemSetting, dispatch) => {
return await SystemSetting.addLocationListener((enable) => {
dispatch(locationAction.setIsLocationEnabled(enable));
});
}; // Components.js
useEffect(() => {
const locationListener = listenLocationChange(SystemSetting, dispatch);
return () => {
if (typeof locationListener?.remove === 'function')
SystemSetting.removeListener(locationListener);
};
}, []); In other word, the fix is to actually add and remove the listeners using Depending on the implementation, these changes could actually be directly in the same component. Edit 2023-09-19: The library's code could actually be updated according to the following stack overflow post: I added the functions to diff --git a/SystemSetting.d.ts b/SystemSetting.d.ts
index 403808c..ab96e4d 100644
--- a/SystemSetting.d.ts
+++ b/SystemSetting.d.ts
@@ -31,6 +31,8 @@ interface VolumeData {
}
interface SystemSetting {
+ addListener: (eventName: string) => void;
+ removeListeners: (count: number) => void;
getBrightness: () => Promise<number>;
setBrightness: (val: number) => Promise<boolean>;
setBrightnessForce: (val: number) => Promise<boolean>;
diff --git a/android/src/main/java/com/ninty/system/setting/SystemSetting.java b/android/src/main/java/com/ninty/system/setting/SystemSetting.java
index 8ade5e6..c5d3adc 100644
--- a/android/src/main/java/com/ninty/system/setting/SystemSetting.java
+++ b/android/src/main/java/com/ninty/system/setting/SystemSetting.java
@@ -199,6 +199,25 @@ public class SystemSetting extends ReactContextBaseJavaModule implements Activit
return SystemSetting.class.getSimpleName();
}
+ /**
+ *
+ * @see https://stackoverflow.com/questions/69538962/new-nativeeventemitter-was-called-with-a-non-null-argument-without-the-requir
+ * @param eventName the name of the event
+ */
+ @ReactMethod
+ public void addListener(String eventName) {
+
+ }
+
+ /**
+ * @see https://stackoverflow.com/questions/69538962/new-nativeeventemitter-was-called-with-a-non-null-argument-without-the-requir
+ * @param count the number of listeners to remove
+ */
+ @ReactMethod
+ public void removeListeners(Integer count) {
+
+ }
+
@ReactMethod
public void setScreenMode(int mode, Promise promise) {
mode = mode == Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL ? mode : Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; |
Hi
I am using this package to get the WIFI state.
When I am running the App I am getting this error -
new NativeEventEmitter()
was called with a non-null argument without the requiredaddListener
method.new NativeEventEmitter()
was called with a non-null argument without the requiredaddListener
method.I have all the installation process and the coing standard as per the document.
Please help me to get rid of that.
The text was updated successfully, but these errors were encountered: