question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this._nativeModule.addListener is not a function. (In 'this._nativeModule.addListener(eventType)', 'this._nativeModule.addListener' is undefined)

See original GitHub issue

Mobile Device Environment

  • Device:Android
  • OS: API28

Application Environment

  • React Native version: v0.61.5
  • RN Bluetooth Classic version: v0.10.9

Describe the bug It was working perfectly. I deleted my node_modules folder, rebuilt it using yarn and ran yarn android and for some reason, I started getting this error whenever I tried to access the listener - whether it was add or remove

To Reproduce

  useEffect(() => {
    RNBluetoothClassic.addListener(
      BTEvents.BLUETOOTH_CONNECTED,
       device => onConnected(device),
     )
    return () => {
       RNBluetoothClassic.removeAllListeners(BTEvents.BLUETOOTH_CONNECTED)
     }
  }, [])

Expected behavior To add and remove listeners without this error

Screenshots CleanShot 2020-09-04 at 18 08 41

Additional context Tried re-installing, changing versions and searching the web, nothing seems to solve the issue - any help would be appreciated

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
kenjdavidsoncommented, Sep 7, 2020

the this._nativeModule looks like it’s being set. Sadly it looks like non of the @ReactMethod methods are being added from the Android public interface RCTEventEmitter. If they’ve changed something within Android that stops the Interface @ReactMethod from being pulled into the bridged module, then this is going to have to be completely re-written sadly.

0reactions
kenjdavidsoncommented, Jan 14, 2021

This shouldn’t be an issue any more in the current version, I’ve removed and reworked the Android native code so that the EventEmitter logic is all within the Module. I’m not a big fan of it, but Facebook seems to not give a shit with regards to the issue that was opened there.

So we’ll leave it as an internal fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

this._nativeModule.addListener is not a function (iOS, RN v0 ...
I'm encountering this issue when upgrading to v0.27.2 (iOS) I think I have the same issue as this: fbsamples/f8app#62.
Read more >
this._nativeModule.addListener is undefined - Stack Overflow
addListener is not a function ... this._nativeModule.addListener is undefined. I tried everything and also rm -rf node_modules then nom ...
Read more >
Upgrading to 0.30.0 Unhandled JS Exception - React Native
Upgrading to 0.30.0 Unhandled JS Exception: this._nativeModule.addListener is not a function. (In this._nativeModule.addListener ). Nicolas Charpentier.
Read more >
ScalablyTyped/community - Gitter
@oyvindberg I've just noticed that SlinkyTyped is not published to bintray. ... _nativeModule = nativeModule; } } addListener( eventType: string, ...
Read more >
Updates - Expo Documentation
Updates.addListener(listener) ... Adds a callback to be invoked when updates-related events occur (such as upon the initial app load) due to auto-update settings ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found