This repository has been archived by the owner on May 12, 2023. It is now read-only.
"Invariant Violation: Module RCTDeviceEventEmitter is not a registered callable module (calling emit)" most likely because of race condition #274
Labels
The application crashes at start with and UI displays error "HMRClient is not a registered callable module". In
adb logcat
I can see that the error comes from callRCTDeviceEventEmitter.emit
.Interestingly, having spent a lot of time troubleshoting this, I found out that issue can easily be worked around.
The error happens when I do at the module level:
But goes away when I import it later on in the render function:
The above works flawelessly.
This leads me to believe that QRCodeScanner or RNCamera performs some initialization at import time and it uses RCTDeviceEventEmitter.emit to post message to JS-side code. When I import it at module level the initialization happens too early and RCTDeviceEventEmitter has not been instantiated yet. So it's a race condition.
By importing at runtime I'm delaying the initialization and this ensures that RCTDeviceEventEmitter has been intialized by this time.
Build details?
This is happening on Android, I haven't checked on Ios yet. I'm using react-native 0.62.0, react-native-qrcode-scanner 1.4.1, react-native-camera 3.30.0, react-native-permissions: 2.1.5.
The text was updated successfully, but these errors were encountered: