Skip to content

Add CurrencySelectorElement (JS)#2445

Merged
porter-stripe merged 8 commits into
masterfrom
porter/currency-selector-js
May 11, 2026
Merged

Add CurrencySelectorElement (JS)#2445
porter-stripe merged 8 commits into
masterfrom
porter/currency-selector-js

Conversation

@porter-stripe
Copy link
Copy Markdown
Collaborator

@porter-stripe porter-stripe commented May 7, 2026

Summary

  • CurrencySelectorElement component with native view spec
  • checkoutSessionDidChangeState event listener in useCheckout

Usage

  import { useCheckout } from '@stripe/stripe-react-native/src/hooks/useCheckout';
  import { CurrencySelectorElement } from '@stripe/stripe-react-native/src/components/CurrencySelectorElement';

  function CartScreen({ clientSecret }: { clientSecret: string }) {
    const { state, checkout } = useCheckout(clientSecret, {
      adaptivePricing: { allowed: true },
    });

    if (!state) return <ActivityIndicator />;

    return (
      <ScrollView>
        {/* Currency selector — collapses to 0 height when adaptive pricing is unavailable */}
        <CurrencySelectorElement
          checkout={checkout}
          disabled={state.status === 'loading'}
        />

        <Text>
          Total: {state.session.totals?.total} {state.session.currency}
        </Text>
      </ScrollView>
    );
  }

Motivation

  • AP in RN

Testing

  • Will add once the component is complete

Documentation

N/A

porter-stripe and others added 4 commits May 7, 2026 11:28
Adds the TypeScript layer for the currency selector feature:
- CurrencySelectorElement component with native view spec
- checkoutSessionDidChangeState event listener in useCheckout
- NativeCurrencySelectorElement codegen spec
- New arch component mapping in package.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Avoids a potential layout flash on mount where the view briefly takes
up unconstrained space before the first onHeightChange event fires.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
No imperative methods are exposed, so forwardRef adds noise with no
benefit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
@porter-stripe porter-stripe changed the title Add CurrencySelectorElement and Checkout state events (JS) Add CurrencySelectorElement (JS) May 7, 2026
* @category ReactComponents
* @internal
*/
export function CurrencySelectorElement({
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Going to export this from index.ts once we are ready to release.

@porter-stripe porter-stripe marked this pull request as ready for review May 11, 2026 18:11
@porter-stripe porter-stripe requested review from a team as code owners May 11, 2026 18:11
@porter-stripe porter-stripe enabled auto-merge (squash) May 11, 2026 18:21
@porter-stripe porter-stripe merged commit 080cc4b into master May 11, 2026
9 checks passed
@porter-stripe porter-stripe deleted the porter/currency-selector-js branch May 11, 2026 19:58
porter-stripe added a commit that referenced this pull request May 12, 2026
Resolves conflicts from the JS and iOS PRs that landed on master:
- Android stub files added in #2445 are replaced by this branch's
  full Compose-based CurrencySelectorElement implementation.
- src/components/CurrencySelectorElement.tsx uses master's
  post-review form (no forwardRef, height initialized to 0).
- src/hooks/useCheckout.tsx keeps master's simpler comment on the
  checkoutSessionDidChangeState listener.

Verified ./gradlew :app:assembleDebug builds successfully.

Co-authored-by: Cursor <cursoragent@cursor.com>
Committed-By-Agent: cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants