react-native-phone-number-input icon indicating copy to clipboard operation
react-native-phone-number-input copied to clipboard

How to handle the validation and getCallingCode if we use multiple phoneInput in single page

Open praveennachi60 opened this issue 2 years ago • 1 comments

Scenerio : Usually, we can validate the phonenumber & country code with help of UseRef of the phone input component. In my case, its dynamic based on the user selection, it will create a number of phoneInput boxes. That time, if the user changed different country code and number means it is validating with last changed countrycode with other phone number.

Problem faced: isvalidNumber & getcallingcode not properly working if multiple phone input boxes.

Expecting: 1. how to solve by using multiple useref? or 2. Any suggestion to validate and get the calling code?

image

praveennachi60 avatar Jun 21 '22 13:06 praveennachi60

I have handled this by putting React-Native-Phone-Number-Input within a component with it's own refs and state. Then you can dynamically render multiple of those parent components.

maxmturner avatar Jan 10 '23 21:01 maxmturner