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

DeviceEventEmitter example in tutorial fails

Open mpj opened this issue 11 years ago • 4 comments

There is an issue with the tutorial, with the sendAppEventWithName call. Screenshot of issue From: https://facebook.github.io/react-native/docs/nativemodulesios.html

This example code will fail with this problem: Screenshot of issue Text for search engine: "Requiring unknown module "RCTNativeAppEventEmitter". If you are sure the modules is there, try restarting the packager.

This is because this call... https://github.com/facebook/react-native/blob/72d3d724a3a0c6bc46981efd0dad8f7f61121a47/React/Base/RCTEventDispatcher.m#L39

Will eventually hit this line, where the error occurs, because there is no RCTNativeAppEventEmitter in the dependency tree. I guess this is because the JavaScript in the example is using the DeviceEventEmitter which is actually requiring the RCTDeviceEventEmitter, not the RCTAppEventEmitter which I cannot find anywhere in the JS code?

Changing the example Objective-C to call sendDeviceEventWithName instead of sendAppEventWithName fixes the problem.

mpj avatar Mar 28 '15 13:03 mpj

:+1: sendDeviceEventWithName works for me as well

tptee avatar Mar 30 '15 04:03 tptee

Seems like #918 is a fix so you can still RCTAppEventEmitter but for now I'm also using the DeviceEventEmitter. It would be good to know what the purpose of the two separate emitters is meant to be...

vitch avatar Apr 21 '15 11:04 vitch

sendDeviceEventWithName works for me too. thanks

xkangai avatar Apr 26 '15 04:04 xkangai

Fixed now!

brentvatne avatar May 31 '15 18:05 brentvatne