react-phone-input-2 icon indicating copy to clipboard operation
react-phone-input-2 copied to clipboard

Placeholder value is ignored if country is used

Open vivekvardhanadepu opened this issue 3 years ago • 4 comments

It would be better if placeholder is still visible next to country code Screenshot 2021-09-21 at 9 54 11 AM

vivekvardhanadepu avatar Sep 21 '21 04:09 vivekvardhanadepu

+1

keanan avatar Nov 30 '21 12:11 keanan

+1

touregeldi avatar Apr 11 '22 13:04 touregeldi

+1

XxOsirisxX avatar Jun 06 '22 23:06 XxOsirisxX

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 😉

hipdev avatar Jul 14 '22 14:07 hipdev

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 😉

dont work)

Nick-Dunne avatar Sep 07 '22 22:09 Nick-Dunne