0.0.4 • Published 5 years ago
rpi-3 v0.0.4
react-phone-input-2-fork
Highly customizable phone input component with auto formatting.
Installation
npm install react-phone-input-2-fork --save
Usage
React.render(
<ReactPhoneInput defaultCountry={'us'} onChange={handleOnChange}/>,
document.getElementById('root')
);
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 handleOnChange(value) {
this.setState({
phone: value
});
}
Options
<ReactPhoneInput
inputExtraProps={{
name: 'phone',
required: true,
autoFocus: true
}}
/>
Regions
Regions selected: {'europe'}
<ReactPhoneInput
defaultCountry='it'
regions={'europe'}
/>
Regions selected: {'north-america', 'carribean'}
<ReactPhoneInput
defaultCountry='ca'
regions={['north-america', 'carribean']}
/>
Localization
<ReactPhoneInput
onlyCountries=['de', 'es']
localization={{'Germany': 'Deutschland', 'Spain': 'España'}}
/>
You can add custom json file like
<ReactPhoneInput
countryData={[
[
"Afganistan",
['asia'],
"af",
"93"
],
[
"Arnavutluk",
['europe'],
"al",
"355"
]
]}
/>
Supported events
Country data object not returns from onKeyDown event
License
Based on react-phone-input-2 using MIT