catamphetamine / react-phone-number-input

React component for international phone number input
http://catamphetamine.gitlab.io/react-phone-number-input/
MIT License
914 stars 193 forks source link

Change country issue #364

Closed hatimmakki closed 3 years ago

hatimmakki commented 3 years ago

Hi

When I have number (says Australia and number 043xxxxxx). When I change the country the country changes to the default country, not to the new selected country. Any solution for this?

this is my code:

 <PhoneInput
          type={type}
          name={name}
          required={required || false}
          value={value || ""}
          id={name}
          disabled={disabled}
          onBlur={e => {
            handleBlur(e);
          }}
          defaultCountry="AU"
          addInternationalOption={false}
          onFocus={e => {
            handleFocus(e.currentTarget.value);
          }}
          onChange={value => {
            // this value is full phone number with country code, e.g. +123123123
            setValue(value);
          }}
        />
hatimmakki commented 3 years ago

solved by changing value={value || ""} to value={value}