presentCustomerCenter throws in preview API mode when callbacks are passed

Open Beginner friendly
#2,050 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@RaphaelFakhri is already working on this.

Since Oct 21, 2026.

  • #2051 by @RaphaelFakhri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react-native, typescript
Domain
api, mobile

Research direction

Start with react-native-purchases-ui/src/preview/nativeModules.ts and trace how RevenueCatUI.presentCustomerCenter handles the preview module’s return value and callback cleanup. The issue describes a Jest reproduction using the real preview module; use it to verify the call returns a promise with and without callbacks. Done means both calls resolve without throwing in preview mode.

Written by the indexing model from the issue text.

Description

Describe the bug

In preview API mode (Expo Go, Rork sandbox, web), RevenueCatUI.presentCustomerCenter({ callbacks }) throws synchronously:

TypeError: Cannot read properties of null (reading 'finally')

The preview RNCustomerCenter module (react-native-purchases-ui/src/preview/nativeModules.ts) returns null from presentCustomerCenter, and RevenueCatUI.presentCustomerCenter calls .finally() on that value to remove its event listeners. Without callbacks, the method returns null instead of the declared Promise<void>, so .then() on the result throws as well.

  1. Environment

    1. Platform: Expo Go / web (preview API mode)
    2. SDK version: react-native-purchases-ui 10.15.0 (current main)
    3. OS version: any
    4. Xcode/Android Studio version: n/a
    5. React Native version: any
    6. SDK installation (CocoaPods + version or manual): npm
    7. How widespread is the issue. Percentage of devices affected: every preview-mode call that passes callbacks
  2. Debug logs that reproduce the issue

A jest test that loads the real preview module and calls RevenueCatUI.presentCustomerCenter({ callbacks }) fails with:

TypeError: Cannot read properties of null (reading 'finally')
  1. Steps to reproduce, with a description of expected vs. actual behavior

  2. Run with the preview native modules (Expo Go or web).

  3. Call RevenueCatUI.presentCustomerCenter({ callbacks: { onRestoreStarted: () => {} } }).

Expected: the call returns a promise that resolves (the method logs that it has no effect in preview mode).
Actual: the call throws TypeError: Cannot read properties of null (reading 'finally').

  1. Other information

Returning a resolved promise from the preview module fixes both call paths.

Dominant language
TypeScript
Stars
1.2k
Forks
124
Avg merge
1d 3h
Merged PRs (30d)
69

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RevenueCat/react-native-purchases

All issues in RevenueCat/react-native-purchases

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.