Description
Problem Description
my code block is below
import {useEffect, useRef} from 'react';
import {DeviceEventEmitter} from 'react-native';
import {NativeEventEmitter, NativeModules} from 'react-native';
const MyModule = NativeModules.MyNativeModule;
const myEventEmitter = new NativeEventEmitter(MyModule);
export default function useEventEmitter(
event: string,
onEvent: (data: any) => void,
) {
const eventRef = useRef(event);
const onEventRef = useRef(onEvent);
useEffect(() => {
const subscribe = myEventEmitter.addListener(
eventRef.current,
onEventRef.current,
);
return () => {
subscribe.remove();
};
}, []);
}
export const emitEvent = (event: string, data?: any) => {
myEventEmitter.emit(event, data);
};
Steps To Reproduce
emitEvent(SHOW_USER_CONSENT_MODAL_EVENT, userDetail);
Expected Results
No response
CLI version
18.0.0
Environment
info Fetching system and libraries information...
System:
OS: Windows 11 10.0.26100
CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Memory: 19.66 GB / 31.85 GB
Binaries:
Node:
version: 22.16.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 10.9.2
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
AllowAllTrustedApps: Enabled
Versions:
- 10.0.18362.0
- 10.0.19041.0
- 10.0.22621.0
- 10.0.26100.0
IDEs:
Android Studio: Not Found
Visual Studio:
- 17.14.36127.28 (Visual Studio Community 2022)
Languages:
Java: Not Found
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.78.0
wanted: 0.78.0
react-native-windows:
installed: 0.78.9
wanted: ^0.78.4
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
info React Native v0.80.0 is now available (your project is running on v0.78.0).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.78.0&to=0.80.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".
Community Modules
No response
Target React Native Architecture
None
Target Platform Version
None
Visual Studio Version
None
Build Configuration
None
Snack, code example, screenshot, or link to a repository
No response