Skip to content

Commit

Permalink
fix(example): ui safe with interaction manager
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Jul 26, 2024
1 parent 8bbc985 commit 45a8852
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {useEffect, useState} from 'react';
import {
Alert,
Button,
InteractionManager,
Pressable,
SafeAreaView,
ScrollView,
Expand All @@ -22,7 +23,7 @@ import {

import {Product, ProductPurchase, PurchaseError} from '../src/ExpoIap.types';

const productSkus = ['com.cooni.point1000', 'com.cooni.point5000'];
const productSkus = ['com.cooni.point1000', 'com.cooni.point5000', 'com.cooni.con5000'];

const operations = ['initConnection', 'getProducts', 'endConnection'];
type Operation = (typeof operations)[number];
Expand Down Expand Up @@ -58,13 +59,17 @@ export default function App() {
useEffect(() => {
const purchaseUpdatedSubs = purchaseUpdatedListener(
(purchase: ProductPurchase) => {
Alert.alert('Purchase updated', JSON.stringify(purchase));
InteractionManager.runAfterInteractions(() => {
Alert.alert('Purchase updated', JSON.stringify(purchase));
});
},
);

const purchaseErrorSubs = purchaseErrorListener(
(error: PurchaseError) => {
Alert.alert('Purchase error', JSON.stringify(error));
InteractionManager.runAfterInteractions(() => {
Alert.alert('Purchase error', JSON.stringify(error));
});
},
);

Expand Down

0 comments on commit 45a8852

Please sign in to comment.