Skip to main content

I keep getting this error in my react native

[TypeError: Cannot read property 'setupPurchases' of null]

I am running react-native with expo bare workflow and running development build but i keep getting that error. This is my code below in App.tsx

 

  useEffect(() => {

    Purchases.setLogLevel(LOG_LEVEL.VERBOSE);

    let apiKey = "";

    if (isIOS) {

      apiKey = REVENUECAT_APPLE_API_KEY;

    } else if (isAndroid) {

      apiKey = REVENUECAT_ANDROID_API_KEY;

    }

    if (!apiKey) {

      console.error("RevenueCat API key is not set");

      return;

    }

    Purchases.configure({ apiKey:apiKey });

  }, ]);

 

I am sure that the api key is being referenced properly and I have also tried upgrading and downgrading the versions of react-native-purchases but i still keep getting this error. Please let me know how to resolve this issue. I have also checked other forums for this issue but still couldn’t find a solution for this. I am currently using     "react-native-purchases": "^8.1.0",
 

Hi! Thank you for reaching out. We typically see this error when there was an issue with installing or importing the SDK. Could you double check that you have installed the SDK correctly using Expo?