To access the call to action feature of the CardView, you can use the useCardView React hook function:
import { CardView, useCardView } from '@card91/react-native-card-view';
export function CardPage() {
const cardView = useCardView();
return (
<View>
<CardView ... />
<Button onPress={cardView.showNumber} title="Show Card Number" />
</View>
);
}
Important
Please make sure that the
CardProvideris placed sufficiently high on the React tree so that both theuseCardViewhook and theCardViewcomponent come under theCardProvider. This works on the React Context design pattern.
The useCardView React hook function provides 5 functions:
| Function | Description |
|---|---|
| copyNumber | Copy the card number onto the OS clipboard. This may not be supported on some devices, wherein an error message can be listened to using the onCopyError prop. |
| hideCVV | Mask the CVV |
| hideNumber | Mask the card number |
| showCVV | Un-mask the CVV |
| showNumber | Un-mask the card number |