-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is no way to put a gap between country code and phone number #33
Comments
I'm about to use this module too and I need a similar thing. But I get you it might be an overkill |
Yup, need this too. Will provide a PR. |
you can do it without hacking the code, actually. Just use libphonenumber-js and the
import React from "react";
import { StyleSheet, View } from "react-native";
import PhoneInput from "react-native-phone-input";
import { formatNumber } from "libphonenumber-js";
type Props = {};
export default class Login extends React.Component<Props> {
constructor(props) {
super(props);
this.onChangePhoneNumber = this.onChangePhoneNumber.bind(this);
this.state = {
phoneNumber: ""
};
}
onChangePhoneNumber(newNumber: string) {
console.log("Setting new number to " + newNumber);
this.setState({
phoneNumber: formatNumber(newNumber, "International")
});
}
render() {
return (
<View style={styles.container}>
<PhoneInput
ref={(ref) => {
this.phone = ref;
}}
onPressFlag={this.onPressFlag}
onChangePhoneNumber={this.onChangePhoneNumber}
value={this.state.phoneNumber}
/>
</View>
);
}
} With this, you can format the number in all the ways that libphonenumber-js does. |
I searched and found there is no way to put a blank space between country code and actual phone number.. I want (+xx xxxxxxxxxx) but it allows me to go with this (+xxxxxxxxxxxx)..
The text was updated successfully, but these errors were encountered: