when I am trying to integrate stripe in react-native component I am getting following error :
Invariant Violation:
new NativeEventEmitter() requires a non-null argument., js engine: hermes
TypeError: Cannot read property 'StripeProvider' of undefined
I have just imported StripeProvider in my component like this =>
import {StripeProvider} from '@stripe/stripe-react-native';
After which I wrapped my component like this and nothing else.
return (
<StripeProvider
publishableKey={STRIPE_PUBLISHABLE_KEY}
merchantIdentifier={STRIPE_MERCHANT_ID}>
<SafeAreaView
style={{flex: 1, backgroundColor: COLORS.DEFAULT_APP.PRIMARY}}>
<View style={styles.mainContainer}>
<Text style={styles.titleMessage}>{title}</Text>
<Text style={styles.subtitleMessage}>{subtitle}</Text>
<NeuMorph
size={window.width * 0.8}
style={{
marginTop: 80,
height: 80,
borderRadius: 12,
flexDirection: 'row',
}}>
<View style={{flex: 2}}>
<Text style={styles.message}>{message}</Text>
<Text style={styles.message}>{subMessage}</Text>
</View>
<View style={{flex: 1}}>
<Text style={styles.price}>{currency + ' ' + price}</Text>
</View>
</NeuMorph>
<View style={{margin: 50}}>
<MaterialIcons
name={materialIcon}
size={80}
color={COLORS.DEFAULT_APP.TERTIARY}
/>
</View>
{note && <Text style={styles.noteMsg}>{note}</Text>}
<View style={styles.bottomContainer}>
<NeuMorphButton
buttonSize={300}
title={buttonTitle}
onPressFunction={subscribe}
buttonStyle={{
borderRadius: 24,
height: 50,
margin: 5,
}}
/>
</View>
</View>
</SafeAreaView>
</StripeProvider>
);
I tried this but it didn’t worked for me
2
Answers
Are you running your react-native project from Expo Go? If it’s, update to the latest version of Expo Go and try again.
Steps to Resolve:
Open Terminal : Open the Terminal on your local machine.
Navigate to Your Project Directory : Use the cd command to navigate to your project directory.
Remove Existing Podfile.lock and Pods Directory : Delete the current Podfile.lock and Pods directory to start with a clean slate.
Remove CocoaPods Cache : Clear the CocoaPods cache to avoid any potential caching issues.
Install CocoaPods : If you don’t have CocoaPods installed, install it using the following command:
Install Pods : Run the following command to install the dependencies specified in your Podfile:
Open the Workspace : If you’re not already using the .xcworkspace file, open it in Xcode:
Clean Build : Clean and build your project to ensure a fresh compilation :
Run Your Project : Run your project to check if the issue is resolved.
Verify the Issue Status : Confirm whether the issue still persists. If it does, please provide additional details or error messages for further assistance.
Notes :
Double-check the paths and commands to avoid any typos or errors.