react-phone-input-2
react-phone-input-2 copied to clipboard
Programmatically select country and dial code
I am using React-Phone-Input-2 in my project. The code is as follows.
<PhoneInput
country={form.$("country").value}
value={form.$("phone").value.countryCode}
enableSearch={true}
countryCodeEditable={false}
placeholder=""
onChange={(phone, country) => {
debugger;
field.set(phone);
}}
inputProps={{
name: "countryCode",
disabled: true,
"data-test": "Address-phone.countryCode",
}}
/>
This works as expected. I can manually select a country and then the country flag and dial code will be displayed.
Now i have a country drop down. When a country is selected from the country drop down, it should programmatically change the country code drop down as well.
I found a similar issue here https://github.com/bl00mber/react-phone-input-2/issues/101. The demo contains a sample but could not find the source code of the example.
Any idea on how to implement this?