skip to Main Content

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

text

2

Answers


  1. Are you running your react-native project from Expo Go? If it’s, update to the latest version of Expo Go and try again.

    Login or Signup to reply.
  2. 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.

      cd /path/to/your/project
      
    • Remove Existing Podfile.lock and Pods Directory : Delete the current Podfile.lock and Pods directory to start with a clean slate.

      rm Podfile.lock
      rm -rf Pods
      
    • Remove CocoaPods Cache : Clear the CocoaPods cache to avoid any potential caching issues.

      pod cache clean --all
      
    • Install CocoaPods : If you don’t have CocoaPods installed, install it using the following command:

      sudo gem install cocoapods
      
    • Install Pods : Run the following command to install the dependencies specified in your Podfile:

      pod install
      
    • Open the Workspace : If you’re not already using the .xcworkspace file, open it in Xcode:

      open YourProject.xcworkspace
      
    • Clean Build : Clean and build your project to ensure a fresh compilation :

       In Xcode, go to Product > Clean Build Folder.
       Then, build the project (Command + B).
      
    • 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 :

    1. Ensure that you have administrative privileges for certain commands (sudo).
    2. Verify that your Xcode project is closed before performing these steps.
      Double-check the paths and commands to avoid any typos or errors.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search