-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Build broken due to duplicate registered views for GooglePayButton and ApplePayButton #1225
Comments
+1 |
Looking into this now! Will have a fix published most likely tomorrow, & thanks very much for trying out the new version |
So I'm only able to reproduce this when importing and rendering both components. Not ideal, but I wouldn't really recommend using both those APIs at once anyways. Let me know if there's a use case for that though. If this is happening without rendering both components, then maybe this has to do with your RN version- I tested this down to RN 0.64 (which is the lowest RN version supported as of v0.8.0 of |
hmmm we're not importing those components though. Here's an exhaustive list of imports that we're using: import { isApplePaySupported, Token, CardField, createToken, createPlatformPayPaymentMethod, StripeProvider } from '@stripe/stripe-react-native';
import { CardFieldInput } from '@stripe/stripe-react-native/src/types';
import { CartSummaryItem } from '@stripe/stripe-react-native/src/types/PlatformPay'; I guess I wouldn't be surprised if the latter two imports had resolution side-effects that end up including something from the various Button components? But we currently need them since we need a type for the |
Hm, copy/pasting those imports still doesn't trigger the error for me on RN 64 |
hmm ok. We'll move forward with a patch-package approach then until we can update our react-native version. If there's anyone else on < react-native 0.64, here's our patch file. If you use it you can't directly use diff --git a/node_modules/@stripe/stripe-react-native/src/components/ApplePayButton.tsx b/node_modules/@stripe/stripe-react-native/src/components/ApplePayButton.tsx
index 9be434f..34aec20 100644
--- a/node_modules/@stripe/stripe-react-native/src/components/ApplePayButton.tsx
+++ b/node_modules/@stripe/stripe-react-native/src/components/ApplePayButton.tsx
@@ -7,8 +7,8 @@ import {
ViewStyle,
} from 'react-native';
-const ApplePayButtonNative =
- requireNativeComponent<ApplePayButtonComponent.NativeProps>('ApplePayButton');
+// const ApplePayButtonNative =
+// requireNativeComponent<ApplePayButtonComponent.NativeProps>('ApplePayButton');
/**
* Apple Pay Button Component Props
@@ -50,13 +50,7 @@ export function ApplePayButton({
const style = useMemo(() => mapButtonStyle(buttonStyle), [buttonStyle]);
return (
- <ApplePayButtonNative
- type={buttonType}
- buttonStyle={style}
- borderRadius={borderRadius}
- onPressAction={onPress}
- {...props}
- />
+ null
);
}
diff --git a/node_modules/@stripe/stripe-react-native/src/components/GooglePayButton.tsx b/node_modules/@stripe/stripe-react-native/src/components/GooglePayButton.tsx
index e8d97ad..d8b1039 100644
--- a/node_modules/@stripe/stripe-react-native/src/components/GooglePayButton.tsx
+++ b/node_modules/@stripe/stripe-react-native/src/components/GooglePayButton.tsx
@@ -8,7 +8,7 @@ import {
StyleSheet,
} from 'react-native';
-const GooglePayButtonNative = requireNativeComponent<any>('GooglePayButton');
+// const GooglePayButtonNative = requireNativeComponent<any>('GooglePayButton');
/**
* Google Pay Button Component Props
@@ -48,7 +48,7 @@ export function GooglePayButton({
onPress={onPress}
style={disabled ? styles.disabled : {}}
>
- <GooglePayButtonNative buttonType={type} {...props} />
+ {/*<GooglePayButtonNative buttonType={type} {...props} />*/}
</TouchableOpacity>
);
}
|
thanks @charliecruzan-stripe for taking a look! |
Thanks for sharing that patch @walkerdb ! but if you are using rn < 64, you may run into this issue on Android: #919. Just wanted to note that and save you some googling Let me know how the migration from |
womp, thanks. |
@charliecruzan-stripe hmm for the record, I still get the same error on react-native 0.64.4. Quite confused because I'm pretty sure the only reason it would happen would be if metro wasn't treeshaking and was instead actually resolving the GooglePayButton import somehow, even though we're not importing it, and no file in the some env details if you end up having time to debug:
Current full import list, spread throughout a few files: import {
CardField,
createPlatformPayPaymentMethod,
createToken,
isPlatformPaySupported,
PlatformPay,
StripeProvider,
Token,
} from '@stripe/stripe-react-native'; Start command: Some of our build config: // react-native.config.js
module.exports = {
transformer: {
// config to allow sentry breadcrumbs to show real names
minifierConfig: {
keep_classnames: true,
keep_fnames: true,
mangle: {
keep_classnames: true,
keep_fnames: true,
},
},
},
}; // babel.config.js
module.exports = function babel(api) {
api.cache(false);
const presets = ['module:metro-react-native-babel-preset'];
const plugins = [
'@babel/plugin-transform-flow-strip-types',
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-react-jsx-source',
'babel-plugin-styled-components',
'@fullstory/react-native',
[
'babel-plugin-module-resolver',
{
extensions: [
'.ios.js',
'.ios.ts',
'.ios.tsx',
'.android.js',
'.android.ts',
'.android.tsx',
'.native.js',
'.native.ts',
'.native.tsx',
'.js',
'.ts',
'.tsx',
'.json',
],
alias: {
'~native': '.',
'~shared': '../../libs/shared',
'~web': '../../apps/web/src',
react: './node_modules/react',
'react-dom': './node_modules/react-dom',
},
},
],
];
return {
presets,
plugins,
env: {
production: {
plugins: ['transform-remove-console'],
},
},
};
}; // tsconfig.json
{
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "react-native.config.js", "jest.config.js"],
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"lib": ["es2019"],
"allowJs": true,
"jsx": "react-native",
"noEmit": true,
"isolatedModules": true,
"strict": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"~web/*": ["../web/src/*"],
"~native/*": ["./*"],
"~shared/*": ["../../libs/shared/*"],
"@tanstack/react-query": ["./node_modules/@tanstack/react-query"],
"react-redux": ["./node_modules/react-redux"]
},
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
|
Let me take a look and see if i can reproduce that @walkerdb , thanks for all the info 🙏 |
I was experiencing this error from simply wrapping a
@walkerdb's patch has made it go away. Thank you. |
I'm on with patch working fine |
hey everyone- @walkerdb I was able to reproduce this using your |
Regardless- will have a fix for this landed soon :) |
Fixed in Fixed in v0.22.1 ✅ |
confirmed thank you!! |
Describe the bug
We're trying out
v0.22.0
to try the newcreatePlatformPayPaymentMethod
flow. With the new version our metro builds fail with the following:This seems to be due to the fact that
@stripe/stripe-react-native
is now internally callingin two different places, once in
src/components/GooglePayButton.tsx
and once insrc/components/PlatformPayButton.tsx
. If we comment out one of the requires (in our casesrc/components/GooglePayButton.tsx
), the build works again** after resolving the GooglePayButton issue we saw the same thing for ApplePayButton, resolved in the same way.
To Reproduce
Run
yarn start
for your app after importingcreatePlatformPayPaymentMethod
, then start up an ios simulator to start the metro dev-server compilation process.Expected behavior
We can build our app with the new
@stripe/stripe-react-native
version.Additional context
We're on
react-native@63
, which may be a factor if you're unable to reproduce on your own machine (further bumping to latest react-native for us was blocked bytipsi-stripe
issues, which is why we're trying to migrate to@stripe/stripe-react-native
).The text was updated successfully, but these errors were encountered: