
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-phone-input-pro
Advanced tools
Phone number input component for react to format phone numbers according to selected countries in real time.
Phone number input component for react to format phone numbers according to selected country in real time.
Run this command in your terminal
npm install react-phone-input-pro
| Props | Description |
|---|---|
| initialFormat: Boolean | When using this component in editable forms. this function automatically guess the the dial code and formats the number |
| prefix: Boolean | user will get dial code pre defined When this is true or undefined |
| className: String | To add a css class in this component |
| includeDialingCode: Boolean | If you don't want to include dial code in number then make this false |
| placeholder: String | To change placeholder |
| onchange: Function() | This function returns current unformatted value. Which you can use to setState of value. |
| onlyCountries: Array | To filter country options. e.g.: ["USA", "IND"] |
| fixLength: Boolean | To limit input length |
| disabled: Boolean | To make input and selector disable |
| fullIsoCode: Boolean | Sets 3 letter ISO Code e.g. "IND", "USA" |
| searchOption: Boolean | To add or remove search bar |
| getCountryCode: Function() | To get selected country code |
| flags: Boolean | To get country code instead of flag |
| error: [errorStatus:boolean, errorMessage:string] | To show error message |
import PhoneInput from 'react-phone-input-pro';
const [number, setNumber] = useState();
const [err, setErr] = useState(false);
//for typescript
const [number, setNumber] = useState<string | number>();
const [err, setErr] = useState(false);
<Controller
control={control}
name={"phone"}
render={({ field: { onChange, value } }) => (
<PhoneInput
value={value}
prefix
onchange={(n: string) => {
onChange(n);
}}
/>
)}
/>
<PhoneInput
initialFormat={true}
value={number}
prefix={true}
onchange={(n) => setNumber(n)}
fullIsoCode={true}
/>

<PhoneInput
value={number}
initialFormat={true}
prefix={true}
placeholder={"Phone number..."}
fixLength={true}
format={"+100 #,##-(###)/##,##"}
fullIsoCode={true}
searchOption={true}
onchange={(n)=> setPhone(n)}
/>
<PhoneInput
value={number}
initialFormat={true}
prefix={false}
placeholder={"Phone number..."}
error={[err, "Invalid Number"]}
fullIsoCode={true}
searchOption={true}
onchange={(value: string)=> {
setNumber(value)
setErr(false);
}}
/>

Based on react-number-formatter
FAQs
Phone number input component for react to format phone numbers according to selected countries in real time.
We found that react-phone-input-pro demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.