npm install --save cleave.js
<script src="cleave.min.js"></script>
<script src="cleave-phone.{country}.js"></script>
import React from 'react';
import ReactDOM from 'react-dom';
import Cleave from 'cleave.js/react';
class MyComponent extends React.Component {
onChange(event) {
// formatted pretty value
console.log(event.target.value);
// raw value
console.log(event.target.rawValue);
}
render() {
return (
<Cleave placeholder="Enter your credit card number"
options={{creditCard: true}}
onChange={this.onChange.bind(this)} />
);
}
}