stripe-react-native: Expo build crashes on both ios and android when using stripe-react-native
Describe the bug App crashes on IOS emulator after app icon clicked (after I remove all stripe-react-native related imports, the app works fine). On Android emulator, it crashes when the method ‘createToken’ is called.
Have not tested it on real devices yet, but the app is working perfectly on Expo Go(Android Expo Go still crashes when calling creatToken).
To Reproduce Steps to reproduce the behavior:
Here’s the code to reproduce the bug:
import React, { useState, useEffect } from "react";
import { View, TextInput } from "react-native";
import Button from "./Button";
import {
CardField,
initStripe,
createToken,
} from "@stripe/stripe-react-native";
const StripePaymentForm = () => {
useEffect(() => {
async function fetchPublishableKey() {
initStripe({
publishableKey: 'your publishable key here',
});
}
fetchPublishableKey();
}, []);
const handleBtnPress = async () => {
const res = await createToken(); // Android build crashes in this step
};
return (
<View>
<CardField
postalCodeEnabled={true}
placeholder={{
number: "4242 4242 4242 4242",
}}
cardStyle={{
backgroundColor: "#FFFFFF",
textColor: "#000000",
borderWidth: 1,
borderRadius: 6,
borderColor: "black",
}}
style={{
width: "100%",
height: 50,
marginVertical: 15,
}}
/>
<Button
title="Create Token"
onPress={handleBtnPress}
/>
</View>
);
};
export default StripePaymentForm;
Expected behavior On IOS the app should not crash on splash screen. On Android, the createToken method should not cause the app to crash.
Desktop (please complete the following information):
- OS: Windows 10 and Mac Big Sur
Smartphone (please complete the following information):
- Device: IPhone 12 emulator, Pixel 3a emulator
- OS: IOS14 and Android 11
Additional context stripe-react-native version: “@stripe/stripe-react-native”: “^0.1.4”,
Please let me know what kind of extra information you need from me in order to debug, thanks!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 24 (2 by maintainers)
I am using managed workflow. The app only crashes in standalone build, so after running the command expo build:iOS, and choose emulator. Then, after the build is done, download it and install it in iOS emulator, the app crashes
@ruida-shen Expo doesn’t support @stripe/stripe-react-native with
expo build
. See the documentation here - https://docs.expo.dev/versions/latest/sdk/stripe/#standalone-appsIf you need a standalone iOS build please use EAS build. Remember to configure the stripe plugin correctly - https://docs.expo.dev/versions/latest/sdk/stripe/#config-plugin-setup-optional
@crosshat yours issue seems to be a different one. Can you please share the way you build the expo ap, error you see and expo and stripe versions? You can create a different issue for that
No, it wasn’t working either, I was hoping upgrading to 0.1.4 will solve the issue, but unfortunately this is not the case.