
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
react-native-phone-entry
Advanced tools
Simple and fully modifiable Phone Number Input Component for React Native
react-native-phone-entry
is a simple and fully modifiable Phone Number Input Component for React Native that provides an intuitive interface for entering and validating international phone numbers. It includes country code selection, number formatting, and validation features.
Looking for an OTP input component to verify phone numbers? Check out react-native-otp-entry - a simple and fully modifiable OTP Input Component for React Native that provides an intuitive interface for entering one-time passwords.
A feature that automatically picks the right country while typing the phone number.
A feature that picks a right mask based on the country code.
npm install react-native-phone-entry
# or
yarn add react-native-phone-entry
import { PhoneInput, isValidNumber } from 'react-native-phone-entry';
export default function App() {
const [countryCode, setCountryCode] = useState < CountryCode > 'US';
return (
<PhoneInput
defaultValues={{
countryCode: 'US',
callingCode: '+1',
phoneNumber: '+1',
}}
onChangeText={(text) =>
console.log(
'Phone number:',
text,
'isValidNumber:',
isValidNumber(text, countryCode)
)
}
onChangeCountry={(country) => {
console.log('Country:', country);
setCountryCode(country.cca2);
}}
/>
);
}
<PhoneInput
defaultValues={{
countryCode: 'US',
callingCode: '+1',
phoneNumber: '+123456789',
}}
value="+123456789"
onChangeText={(text) => console.log('Phone number:', text)}
onChangeCountry={(country) => console.log('Country:', country)}
autoFocus={true}
disabled={false}
countryPickerProps={{
withFilter: true,
withFlag: true,
withCountryNameButton: true,
}}
theme={{
containerStyle: styles.phoneContainer,
textInputStyle: styles.input,
flagButtonStyle: styles.flagButton,
codeTextStyle: styles.codeText,
dropDownImageStyle: styles.dropDownImage,
enableDarkTheme: false,
}}
hideDropdownIcon={false}
isCallingCodeEditable={false}
/>
Prop | Type | Description | Default |
---|---|---|---|
defaultValues | object | Default values for country code, calling code, and phone number | undefined |
value | string | Controlled value for the phone number input | undefined |
onChangeText | (text: string) => void | Callback when phone number changes | undefined |
onChangeCountry | (country: Country) => void | Callback when selected country changes | undefined |
autoFocus | boolean | Automatically focuses the input when mounted | false |
disabled | boolean | Disables the input | false |
countryPickerProps | CountryPickerProps | Props for the country picker modal | {} |
maskInputProps | MaskInputProps | Props for the masked input component | {} |
theme | Theme | Theme configuration for styling the component | {} |
hideDropdownIcon | boolean | Hides the dropdown arrow icon when set to true | false |
renderCustomDropdown | ReactNode | Custom component to replace the default dropdown arrow | undefined |
flagProps | object | Props for customizing the country flag | {} |
dropDownImageProps | ImageProps | Props for customizing the dropdown arrow image | {} |
isCallingCodeEditable | boolean | Controls whether the calling code can be edited | true |
Property | Type | Description | Default |
---|---|---|---|
containerStyle | StyleProp<ViewStyle> | Style for the main container | undefined |
textInputStyle | StyleProp<TextStyle> | Style for the text input | undefined |
codeTextStyle | StyleProp<TextStyle> | Style for the calling code text | undefined |
flagButtonStyle | StyleProp<ViewStyle> | Style for the flag button | undefined |
dropDownImageStyle | StyleProp<ImageStyle> | Style for the dropdown arrow image | undefined |
enableDarkTheme | boolean | Enables dark theme for the component | false |
isValidNumber(phoneNumber: string, countryCode: string): boolean
Validates a phone number for a specific country using Google's libphonenumber.
import { isValidNumber } from 'react-native-phone-entry';
const isValid = isValidNumber('+1234567890', 'US');
This library depends on the following packages:
See the contributing guide to learn how to contribute to the repository and the development workflow.
This project is licensed under the MIT License.
Made with create-react-native-library
Inspired by react-native-phone-number-input
FAQs
Simple and fully modifiable Phone Number Input Component for React Native
The npm package react-native-phone-entry receives a total of 257 weekly downloads. As such, react-native-phone-entry popularity was classified as not popular.
We found that react-native-phone-entry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.