-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetNativeEventListeners.js
More file actions
21 lines (19 loc) · 984 Bytes
/
setNativeEventListeners.js
File metadata and controls
21 lines (19 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* expressCartMobile
* https://github.com/atmulyana/expressCartMobile
*
* @format
* @flow strict-local
*/
import {noop} from './common';
module.exports = nativeModuleName => {
/** This function exists in order to avoid warning message:
* `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
* `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
* The message shows when importing a module containing declaration of 'new NativeEventEmitter(nativeModule)'
* The message seems to appear in RN version 0.65+, not in version before
*/
let nativeModule = require('react-native').NativeModules[nativeModuleName] ?? {};
if (typeof(nativeModule.addListener) != 'function') nativeModule.addListener = noop;
if (typeof(nativeModule.removeListeners) != 'function') nativeModule.removeListeners = noop;
}