facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.04k stars 24.07k forks source link

this._nativeModule.addListener is not a function (iOS, RN v0.27.2) #8025

Closed oureta closed 8 years ago

oureta commented 8 years ago

I'm encountering this issue when upgrading to v0.27.2 (iOS)

I think I have the same issue as this: https://github.com/fbsamples/f8app/issues/62

oureta commented 8 years ago

This is due to KeyboardObserver native module

rnpm link fixes the problem

simonjblack commented 7 years ago

this unforunately didn't fix this error for me after upgrading from v0.24.0 to v0.29.0 (iOS). I also tried removing node_module and re-running npm install to no avail :(

Anyone found a solution that works for v0.29.0?

AlePue commented 7 years ago

+1 for RN 0.29

mebinum commented 7 years ago

+1 for RN 0.30 anybody know why this is happening

sgwilym commented 7 years ago

Also having this problem with RN 0.30.0-rc.0.

n8stowell82 commented 7 years ago

I have been having this problem as well. here is what I have done to fix it for my project. Please let me know if this helps you in any way.

  1. follow the steps above with rm -rf node_modules && npm install and then rnpm link
  2. make sure to follow the upgrade instructions on the 0.27 release notes post -> https://github.com/facebook/react-native/releases/tag/v0.27.0
    • specifically replace any references to DeviceEventEmitter with Keyboard
  3. run from Xcode not command line. This worked for me as a way to get the project up and running. The project would run fine from Xcode but fail when run with react-native run-ios
  4. if project runs from xcode but will not run from command line you most likely have a cached version of the build that needs to be killed.
    • Navigate to your project in finder and locate the iOS/build folder and open it
    • Destroy the contents of this folder (you can probably get by just deleting the "Intermediates" folders, but make sure to check inside nested folders to find all instances of "Intermediates". This is why I just kill the whole thing
    • run sudo react-native run-ios to rebuild the project and run it
    • if you get a message saying "no devices booted" then run react-native run-ios after running previous command

If this didn't work for you then try running react-native upgrade before step walking through step 4. Be careful with the upgrade command if you have any custom logic outside of RN in you xcode project as this command will reset the project to default settings. You can evaluate each question with hitting d to see what changes are trying to be made.

Hopefully this helps someone

zo-chu commented 7 years ago

unfortunately, this doesn't work for my case... rn 0.31 trying to set up PushNotifications and each time see this red screen 'this._nativeModule.addListener is not a function'

Any thoughts what can cause it?

amaanmemon commented 7 years ago

@zo-chu : did you find any solutions, same issue here If found, please post the solution, Thanks

kkkelicheng commented 6 years ago

I have found that if in nativeModule do not sendEventWithName:eventA but in ReactNative nativeEventEmitter.addListener: eventA。 could occur that error I think it may help who have this issue