Payment Credit Card Input For React

Category: Form , React
Author:medipass
Views Total:8 views
Official Page:Go to website
Publish Date:September 10, 2020
License:MIT

A React Hook & Container to help with payment credit card input fields.

Install & Import:

# Yarn
$ yarn add react-payment-inputs

# NPM
$ npm i react-payment-inputs --save
import React from 'react';
import { usePaymentInputs } from 'react-payment-inputs';

Basic Usage:

export default function PaymentInputs() {
  const { meta, getCardNumberProps, getExpiryDateProps, getCVCProps } = usePaymentInputs();
  return (
    <div>
      <input {...getCardNumberProps({ onChange: handleChangeCardNumber })} value={cardNumber} />
      <input {...getExpiryDateProps({ onChange: handleChangeExpiryDate })} value={expiryDate} />
      <input {...getCVCProps({ onChange: handleChangeCVC })} value={cvc} />
      {meta.isTouched && meta.error && <span>Error: {meta.error}</span>}
    </div>
  );
}

Preview:

Payment Card Input For React

You Might Be Interested In:

Leave a Reply