You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const [phone, setPhone] = useState<string>("")
// Some asynchronous calls that will setPhone()
return (<PhoneInput
value={phone}
label="Phone"
onChange={(phone) => {
setPhone(phone);
}}
/>)
The problem is that in your implementation you don't make any difference between onChange from the client and onChange from your own system adding the country code (e.g. +1) so in my case I'm having my API response being overwritten by an additional +1 for no reason.
The only workaround I found was to detect onFocus and activate onChange once the user actually goes on that phone input.
This is an abstract of my solution, it's not perfect. A better solution would be to avoid firing onChange when initializing the country code, or at least have another type of event for that.
The text was updated successfully, but these errors were encountered:
Hey @Loschcode!
Are you sure that the phone value that you are setting asynchronously starts with +?
Can you also share a piece of logic where you are setting a new phone value to the phone input, please? 🙏
If you change value prop everything should work fine...
I'm using GraphQL and will receive some phone asynchronously. Long story short, the example in your documentation is not working properly because it doesn't take into consideration asynchronous data coming in.
The problem is that in your implementation you don't make any difference between
onChange
from the client andonChange
from your own system adding the country code (e.g.+1
) so in my case I'm having my API response being overwritten by an additional+1
for no reason.The only workaround I found was to detect
onFocus
and activateonChange
once the user actually goes on that phone input.This is an abstract of my solution, it's not perfect. A better solution would be to avoid firing
onChange
when initializing the country code, or at least have another type of event for that.The text was updated successfully, but these errors were encountered: