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

Default value not loading on initial page load #698

Open
gyannickange opened this issue Oct 3, 2024 · 0 comments
Open

Default value not loading on initial page load #698

gyannickange opened this issue Oct 3, 2024 · 0 comments

Comments

@gyannickange
Copy link

Description:

I am encountering an issue where the default value of the PhoneInput component is not displayed when the page is initially loaded. The component does not recognize the default value on the first render.

Steps to Reproduce:

  1. Set a default value for the PhoneInput using the value prop.
  2. Load the page and observe that the default value is not displayed in the input field.

Expected Behavior:

The PhoneInput should display the default value when the page is first loaded.

Actual Behavior:

The input field remains empty on the initial load, but the value appears after the hot reload.

Code Example:

<PhoneInput
  country="bj"
  value="+22996669509"  // Default phone number
  countryCodeEditable={false}
/>

Environment:

react-phone-input-2 version: ^2.15.1
React version: ^18.3.1

Additional Information:

I've tried multiple ways to set the default value, including using useState, but the behavior is consistent across approaches. It seems related to how the component initializes the value on the first render.

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

1 participant