stripe-react-native
stripe-react-native copied to clipboard
App Crashing when I try to use `stripe/stripe-react-native` | Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes
Describe the bug
I followed the instructions to install @stripe/stripe-react-native. Since I'm using Expo, I used expo install @stripe/stripe-react-native to install the correct version. I also had to downgrade @stripe/stripe-identity-react-native to be compatible with the version of @stripe/stripe-react-native that was installed.
As soon as I import anything from @stripe/stripe-react-native the app just crashes with the following error: Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes
To Reproduce
Steps to reproduce the behavior:
Install @stripe/stripe-react-native and try to import StripeProvider
As soon as I import anything from the library my app crashes.
import { StripeProvider } from "@stripe/stripe-react-native";
Expected behavior App not crashing
Screenshots
Smartphone (please complete the following information):
- Device: iOS Simulator (iPhone 15 Pro Max)
- OS: iOS17.2
Additional context
- "react-native": "0.73.4",
- "@stripe/stripe-identity-react-native": "0.2.2",
- "@stripe/stripe-react-native": "~0.35.1",
cc @charliecruzan-stripe
hi @petrovicstefanrs could you try the latest release of stripe-identity-react-native 0.2.8 and stripe-react-native 0.37.3 ?
Hi @ccen-stripe I'm still facing the same issue.
While I was able to make a build this time using the latest lib versions (this was failing consistently the last time i tried it), I'm still not able to get the stripe-react-native lib to not crash. Take a look at what happens as soon as I import StripeProvider from the library https://www.loom.com/share/c12483ac7dcf4b7f97eaf35c307cf37b
Hi! This indicates an issue with your local project. In this library, we call NativeEventEmitter with NativeModules.StripeSdk, so this means you're getting null back for that value. I would recommend clearing out your pods and re-pod installing and trying again.
Since you're using Expo, make sure you use the proper version of @stripe/stripe-react-native (you can see our changelog for which version to use, or use expo install).
@charliecruzan-stripe
Thanks for the reply, but unfortunately that didn't help. To make sure nothing was interfering, I started from a clean branch and just added the failing @stripe/stripe-react-native that I installed with the expo install command.
It installed "@stripe/stripe-react-native": "~0.35.1" - Which is the version I was trying out initially when I opened this issue. I removed Pods, Podfile.lock, re-installed all pods, and I'm still getting the same error.
Could you send me the exact steps & commands you're taking? Including things like if you're running this in Expo Go, etc. basically as much detail as possible, OR share a fresh project with me that reproduces the error, and then i can help debug
Last night, as I was doing it all again from the start, on a clean branch, so I could document the steps for you, it actually worked.
I would assume that removing Podfile.lock, Pods folder, and then reinstalling everything did the trick. Not sure why it didn't work the first time around but at least it's working.
Thank you for your time @charliecruzan-stripe!