stripe / stripe-react-native

React Native library for Stripe.
https://stripe.dev/stripe-react-native
MIT License
1.28k stars 263 forks source link

AddressSheet doesn't trigger callbacks after upgrading to react-native 0.76.2 #1779

Open Dreamer93 opened 1 day ago

Dreamer93 commented 1 day ago

Describe the bug AddressSheet component doesn't trigger onError or onSubmit callbacks anymore. It was working fine on react-native version 0.74. I am using Expo (v 52) and I tried using 3 different versions of this module (38.6, 39.0 and 40.0) and neither works. To Reproduce Steps to reproduce the behavior:

  1. Create new Expo project through their CLI npx create-expo-app@latest
  2. Reset project npm run reset-project
  3. Replace index.tsx with
    
    import { Button, Text, View } from "react-native"
    import { AddressSheet, StripeProvider } from "@stripe/stripe-react-native"
    import { useMemo, useState } from "react"

export default function Index() { const [visible, setVisible] = useState(false) const addressDefaultValues = useMemo(() => { return { name: "John Doe", address: { city: "San Francisco", country: "US", line1: "123 Market St", line2: "Suite 500", postalCode: "94103", state: "CA" } } }, []) return ( <StripeProvider publishableKey={"some_stripe_pk_key"}

<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}

Edit app/index.tsx to edit this screen.

<Button title={"Open Address Sheet"} onPress={() => { setVisible(true) console.log("im here") } }> <AddressSheet visible={visible} defaultValues={addressDefaultValues} onSubmit={(data) => { console.log(data) setVisible(false) }} onError={(err) => {console.log(err)}}> ) }


4. Start the app
5. Click on the Open Address Sheet button
6. Click Save address button
7. Observe no log and inability to open the sheet again due to visible not being reset

**Expected behavior**
Expectation is for onSubmit and onError to trigger

**Additional context**

My presumption is that there is a change to how native components should be merged into react-native:
[0.74 native components](https://reactnative.dev/docs/0.74/native-components-android)
[0.76 native components](https://reactnative.dev/docs/fabric-native-components-introduction)