cjam / react-native-spotify-remote

React Native wrapper around the Spotify Remote SDK
MIT License
258 stars 101 forks source link

Example NativeEventEmitter.js error (this._nativeModule.addListener is not a function) #232

Open mdloucks opened 1 year ago

mdloucks commented 1 year ago

After cloning the repo and running the example/ code, I was greeted with the following error. This looks like an issue in the EventEmmiter library. This happens after following the README.md to set up the example project for the first time.

The app throws this error immediately when it starts up. I believe the library in question is being used by SpotifyRemote.ts. Everything was installed using yarn. I tried changing the react native version to no avail. This is being run on a physical iPhone device using Xcode on M2.

Error


[Thu Feb 16 2023 17:24:40.607] ERROR TypeError: this._nativeModule.addListener is not a function. (In 'this._nativeModule.addListener(eventType)', 'this._nativeModule.addListener' is undefined)

This error is located at: in AppContextProvider (at App.tsx:50) in App (at renderApplication.js:45) in RCTView (at View.js:34) in View (at AppContainer.js:106) in RCTView (at View.js:34) in View (at AppContainer.js:132) in AppContainer (at renderApplication.js:39)

[Thu Feb 16 2023 17:37:20.100] BUNDLE ./index.js


All code is default from master except for a couple changes

Podfile Includes (Fix for this issue)

pod 'RNSpotifyRemote', :path => '../node_modules/react-native-spotify-remote' pod 'RNEventEmitter', :path => "../node_modules/react-native-events"

Package.json dependencies

"peerDependencies": {
    "react-native": "0.60"
},
"dependencies": {
    "react-native-spotify-remote": "1.0.0-1"
},
"devDependencies": {
    "@release-it/keep-a-changelog": "^2.2.2",
    "@types/react-native": "0.60.0",
    "all-contributors-cli": "^6.14.2",
    "concurrently": "^5.0.2",
    "release-it": "^14.6.1",
    "typedoc": "^0.20.24",
    "typescript": "^4.1.3"
},

platform :ios, '10.0'

cjam commented 1 year ago

Seems like a bug. There was a PR a while back around removing the react-native-events as a dependency, but I feel that maybe some work was missing for the changes within the example app.

I've unfortunately been so busy with work I haven't been able to put any time to this project :(

mdloucks commented 1 year ago

You're right, I remember seeing that as well. No worries though! I went ahead and just made the project using Swift. It's a shame the Spotify devs don't have anything for Flutter/React. Thanks for the help :)