Skip to content
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

this._nativeModule.addListener is not a function #41

Open
1 task
Sunjiawei58 opened this issue Jan 9, 2018 · 2 comments
Open
1 task

this._nativeModule.addListener is not a function #41

Sunjiawei58 opened this issue Jan 9, 2018 · 2 comments

Comments

@Sunjiawei58
Copy link

Sunjiawei58 commented Jan 9, 2018

Dev setup:

  • react-native-create-bridge version: 1.2.2
  • react-native version: 0.49.3

I am using create-bridge in a:

  • standalone library
  • [yes ] existing React Native project

What you did:

I followed this tutorial video : https://www.youtube.com/watch?v=OrIIPNEjQfs
to create a object-c Native Module. the constant and the general method works perfectly, but

What happened:

when I receive the event in the JS side using
emitter.addListener('EXAMPLE_EVENT,({greeting}) =>{console.log(greeting)}').
It said "this._nativeModule.addListener is not a function"

Do you have any ideas on how that happens?

Thanks for any help

@dbasea
Copy link

dbasea commented May 17, 2018

Are you using redux/react navigation in your application? I'm having the same problem and trying to pin down the reason.

@AksimO
Copy link

AksimO commented Jul 3, 2018

Your generate generated a little bit different files that showed in this video.
Pay attention to a header file.
In video header file HelloWorld.h contains #import “RCTEventEmitter.h”, but your generated file doesn't.
As well definition of interface should be

@interface HelloWorldComponent : RCTEventEmitter <RCTBridgeModule>
  // Define class properties here with @property
@end

instead of

@interface HelloWorldComponent : NSObject <RCTBridgeModule>
  // Define class properties here with @property
@end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants