1.0.2 • Published 6 years ago

react-geoip-phone-input-new v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

react-phone-input

A simple react component to format a phone number as the user types with integrated user country detection via geoIp provided by ip-api.io. (forked from https://github.com/razagill/react-phone-input)

Live demo

Click to see live demo

alt tag

Installation:

npm install react-geoip-phone-input --save

Usage:

React.render(
  <ReactPhoneInput defaultCountry={'us'} onChange={handleOnChange)/>,
  document.getElementById('content'));

Your handler for the onChange event should expect a string as parameter, where the value is that of the entered phone number. For example:

function handeOnChange(value) {
   this.setState({
      phone: value
   });
}

Options:

NameDescription
valuestring, phone number value
defaultCountrycountry code to initialize the component
excludeCountriesarray of country codes to be excluded e.g. 'cu','cw','kz'
onlyCountriesarray of country codes to be included e.g. 'cu','cw','kz'
preferredCountriesarray of country codes to be preferred (highlighted at the top) e.g. 'cu','cw','kz'
ipGeocodingEnabledboolean flag to turn on/off ip geocoding (default - true)

License

MIT