Skip to content

fix: use platform-specific stubs for Apple Pay and Google Pay native components#36

Open
arstiefel wants to merge 1 commit intomainfrom
fix-use-platform-specific-stubs
Open

fix: use platform-specific stubs for Apple Pay and Google Pay native components#36
arstiefel wants to merge 1 commit intomainfrom
fix-use-platform-specific-stubs

Conversation

@arstiefel
Copy link
Collaborator

@arstiefel arstiefel commented Mar 24, 2026

Description

Fixes a Metro bundler crash caused by codegenNativeComponent being called at module load time for platform-exclusive native components. On Android, codegenNativeComponent('BoltApplePayButton') runs during bundling even though Apple Pay is iOS-only, and Metro cannot find the Fabric component config, resulting in a hard bundler failure (the inverse applies on iOS for Google Pay).

The fix introduces platform-specific stub files: ApplePay.android.tsx returns null on Android, and GoogleWallet.ios.tsx returns null on iOS. Metro automatically resolves the correct file per platform, so the real codegenNativeComponent calls only execute on their native platform. The stubs are never rendered in practice because the parent components already guard behind Platform.OS checks. Also bumps SDK_VERSION to 0.5.2.

Testing

  • Build and run on Android — confirm the Metro bundler error Could not find component config for native component no longer occurs.
  • Build and run on iOS — confirm Apple Pay renders and functions correctly.
  • Build and run on Android — confirm Google Pay renders and functions correctly.
  • Build and run on iOS — confirm Google Pay stub does not cause any crash (guarded by Platform.OS === 'android' in GoogleWallet).
  • Verify SDK_VERSION reads 0.5.2 in telemetry output.

Security Review

Important

A security review is required for every PR in this repository to comply with PCI requirements.

  • I have considered and reviewed security implications of this PR and included the summary below.

Security Impact Summary

No security-sensitive changes. This PR only modifies how native UI components are resolved per platform at bundle time. It does not affect payment logic, authentication, data handling, or any external integrations.

@arstiefel arstiefel requested review from a team as code owners March 24, 2026 20:42
@snyk-io
Copy link

snyk-io bot commented Mar 24, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Metro bundler crashes by preventing codegenNativeComponent from running at module load time for platform-exclusive (Apple Pay / Google Pay) Fabric components.

Changes:

  • Replaced the cross-platform native component modules with lightweight stubs exporting a plain View.
  • Added platform-specific implementations (.ios.ts / .android.ts) that contain the real codegenNativeComponent calls.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/native/NativeGooglePayButton.ts Converts the default module into an iOS/non-Android stub to avoid Android-only codegen at bundle time.
src/native/NativeGooglePayButton.android.ts Adds Android-specific codegenNativeComponent implementation for the Google Pay button.
src/native/NativeApplePayButton.ts Converts the default module into an Android/non-iOS stub to avoid iOS-only codegen at bundle time.
src/native/NativeApplePayButton.ios.ts Adds iOS-specific codegenNativeComponent implementation for the Apple Pay button.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arstiefel arstiefel force-pushed the fix-use-platform-specific-stubs branch 3 times, most recently from abbd379 to 2d92299 Compare March 24, 2026 21:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants