US telephone mask for text input
npm i rn-phone-number-mask
Transforms 1234567890 into (123) 456-7890 dynamically
Import
import PhoneNumberMask from 'rn-phone-number-mask'
And use it this way:
<PhoneNumberMask
containerStyle={styles.containerStyle}
style={styles.inputStyle}
onNumberChange={phoneNumber => this.setState({ phoneNumber })} />
Prop | Description | Type | Default |
---|---|---|---|
onNumberChange |
This function is triggered when TextInput value changes (returns value with mask applied) | Function | Required |
containerStyle |
TextInput container style | Object | {} |
style |
InputText style | Object | {} |
maxLength |
Max length of phone number | Number | 14 |
Enjoy!