Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting initialCountry using state #48

Open
ravindra-encoresky opened this issue Apr 20, 2023 · 1 comment
Open

Setting initialCountry using state #48

ravindra-encoresky opened this issue Apr 20, 2023 · 1 comment

Comments

@ravindra-encoresky
Copy link

ravindra-encoresky commented Apr 20, 2023

I'm facing this problem : trying to pre-set initialCountry but it doesn't work. It shows US flag every time.

        <PhoneInput
            style={{ width: wp('10%'), height: wp('10%') }}
            textProps={{
              placeholder: '',
              fontSize: hp('1.7991%'),
            }}
            initialCountry={this.state.initialCountry}
            ref={this.props.setPhoneRef}
            onPressFlag={() => {
              this.props.onPressFlag();
            }}
          />
          

Can anyone please share how can I achieve this or if this feature still needs to be developed.

thanks.

@ishanVaghasiya
Copy link

I have also faced the same problem.
but the solution below works for me.

use set your initial country code as initialValue props

for ex. if I want to set India as the default country

<PhoneInput
            ref={phoneRef}
            initialCountry={'in'}   <---- not working in my case
            initialValue="91"    <--- I have do this 
            textProps={{
                placeholder: 'Enter a phone number...'
            }}
        />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants