This patch fixes the codegen issue that occurs when using @stripe/stripe-react-native versions before 0.52 with React Native 0.74+ in the old architecture.
When using React Native 0.74+ with the old architecture, you may encounter this error during pod install:
UnsupportedModulePropertyParserError: Module NativeStripeSdkModule: TypeScript interfaces extending TurboModule must only contain 'FunctionTypeAnnotation's. Property 'onConfirmHandlerCallback' refers to a 'TSTypeReference'.
This occurs because the React Native codegen in the old architecture doesn't support EventEmitter properties in TurboModule interfaces.
If possible, update to version 0.52 or above of the Stripe React Native SDK. If you are unable to do so, use the old-arch-codegen-fix patch.
This patch converts all EventEmitter properties to callback function methods, making them compatible with the old architecture codegen.
cd node_modules/@stripe/stripe-react-native
patch -p0 < patches/old-arch-codegen-fix.patch-
Install patch-package as a dev dependency:
npm install --save-dev patch-package
-
Apply the patch manually first:
cd node_modules/@stripe/stripe-react-native patch -p0 < ../../patches/old-arch-codegen-fix.patch
-
Generate a patch-package patch:
npx patch-package @stripe/stripe-react-native
-
Add postinstall script to your
package.json:{ "scripts": { "postinstall": "patch-package" } }
This ensures the patch is automatically applied whenever you run npm install.