Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 967 Bytes

using_hooks.md

File metadata and controls

50 lines (37 loc) · 967 Bytes
sidebar_position
6

Using hooks

How to use hooks

  1. You have to wrap your app with the withIAPContext HOC
import {withIAPContext} from 'react-native-iap';

const App = () => <View />;

export default withIAPContext(App);
  1. Later then, somewhere in your components
import {useIAP} from 'react-native-iap';

const YourComponent = () => {
  const {
    connected,
    products,
    promotedProductsIOS,
    subscriptions,
    purchaseHistories,
    availablePurchases,
    currentPurchase,
    currentPurchaseError,
    initConnectionError,
    finishTransaction,
    getProducts,
    getSubscriptions,
    getAvailablePurchases,
    getPurchaseHistories,
  } = useIAP();

  return <View />;
};

Reference

From [email protected]+ we support the useIAP hook that handles purchases better.

Check this Medium post for usage instructions.