Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: useIap hook #9

Merged
merged 2 commits into from
Oct 27, 2024
Merged

feat: useIap hook #9

merged 2 commits into from
Oct 27, 2024

Conversation

hyochan
Copy link
Owner

@hyochan hyochan commented Oct 26, 2024

Copy link

github-actions bot commented Oct 26, 2024

Risk Level 2 - /home/runner/work/expo-iap/expo-iap/src/useIap.ts

  1. The useIAP hook is well-structured, but the finishTransaction function is recursively calling itself, which could lead to a stack overflow. Consider renaming the imported finishTransaction to avoid this conflict.

Example:

import { finishTransaction as finishTransactionModule } from './';

const finishTransaction = useCallback(
  async ({ purchase, isConsumable, developerPayloadAndroid }) => {
    try {
      return await finishTransactionModule({
        purchase,
        isConsumable,
        developerPayloadAndroid,
      });
    } catch (err) {
      throw err;
    } finally {
      if (purchase.productId === currentPurchase?.productId) {
        setCurrentPurchase(undefined);
      }

      if (purchase.productId === currentPurchaseError?.productId) {
        setCurrentPurchaseError(undefined);
      }
    }
  },
  [currentPurchase?.productId, currentPurchaseError?.productId, setCurrentPurchase, setCurrentPurchaseError],
);
  1. Ensure that all subscriptions are properly cleaned up in the useEffect cleanup function to prevent memory leaks.

🔄🛠️🧹


Powered by Code Review GPT

@hyochan hyochan merged commit 9821608 into main Oct 27, 2024
3 checks passed
@hyochan hyochan deleted the feat/useIap branch October 27, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant