bl00mber / react-phone-input-2

:telephone_receiver: Highly customizable phone input component with auto formatting
https://bl00mber.github.io/react-phone-input-2.html
MIT License
948 stars 536 forks source link

Need the ability to show placeholder when default country is selected but number input is empty #355

Open WaqqarSuleman opened 3 years ago

WaqqarSuleman commented 3 years ago

Hi,

I have a requirement where I need the ability to show placeholder when default country is selected but number input is empty. Any help would be appreciated.

MartinDesrosiers commented 3 years ago

Hi @WaqqarSuleman, Did you find a solution for this issue? I'm facing the same problem. Thanks!

WaqqarSuleman commented 3 years ago

Hi @WaqqarSuleman, Did you find a solution for this issue? I'm facing the same problem. Thanks!

Nope.

instakash commented 3 years ago

Same problem here. I cannot show the placeholder either.

xtrinch commented 3 years ago

Bump. Same here.

groteck commented 2 years ago

Bump

XxOsirisxX commented 2 years ago

+1

hipdev commented 2 years ago

Hi folks, try this:


  const [value, setValue]= useState('')
  // ...

  useEffect(() => {
    // tricky way of set as empty the phoneInput with a country code selected

    let timer = setTimeout(() => setValue('1'), 100)  // or whatever state you have, Formik, RHF...
    let timer2 = setTimeout(() => setValue(''), 200)
    return () => {
      clearTimeout(timer)
      clearTimeout(timer2)
    }
  }, [])

  // ... add value to your PhoneInput component like always...

Voilà, it works 😉