'how to reset the phone number text field when you change the country code
in react phone input one property is there international that helps but in react phone input 2 this property is not working. In the react phone input 2 if you want to change the country code after filling the all digit then country code is changed but remaining digit are not removed automatically, in react phone number its was happening automatically. as for example if you given 91-9787890000 then if you change the code 91(India) to 852(Hong Kong) then its should look like 852 in phone text field but now its give 85297878900 how to reset those digit 
import React, { useState } from "react";
import PhoneInput from "react-phone-input-2";
import "react-phone-input-2/lib/material.css";
export default function DropDown() {
const [fields1, setFields1] = useState([{ value: null }]);
function handleChange(i, event) {
if (event) {
let values = [...fields1];
values[i].value = event;
setFields1((v) => values);
}
}
return (
<div className="App">
{fields1.map((field, idx) => (
<PhoneInput
country={"in"}
key={idx}
localization={'in'}
enableSearch
disableSearchIcon={false}
specialLabel=""
autoComplete="off"
value={field.value || ""}
onChange={(e) => {handleChange(idx, e);}}
/>
))}
</div>
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

