Function 'onChangePhoneNumber' is called with empty value every time component is rendered even with defaultValue #24
Unanswered
victorgoecking
asked this question in
Q&A
Replies: 1 comment 1 reply
-
hey @victorgoecking I tried to reproduce your situation using the example on README with React-Hook-Form + Typescript + Default Phone Number Value and the input value dont stay empty after rerender... Can you deploy this code anywhere? Maybe, I (or another) can help you... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using "React-Hook-Form + Typescript + Default Phone Number Value". I receive the api data already passed to the hook-form's defaultValue and also passing the "value" and "defaultValue="+5500999999999" in the , but when the component is rendered it calls the "onChangePhoneNumber" function defining the value as empty.
I'm using a small strategy to check if it's the first rendering so as not to set an empty value.
![image](https://private-user-images.githubusercontent.com/9842243/281411093-2481bf96-7952-41ab-92e4-87f402da0d2b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NjQ2ODUsIm5iZiI6MTcyNDc2NDM4NSwicGF0aCI6Ii85ODQyMjQzLzI4MTQxMTA5My0yNDgxYmY5Ni03OTUyLTQxYWItOTJlNC04N2Y0MDJkYTBkMmIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMTMxMzA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjllMzBhMjE0ODZhYWE4MGEyNGNmYTg3YTM0OTMwMGFmNDJjYTBjNzYwMDU2YzVkYTY5MjI5MmRmY2VhZjQ2NyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Nx18B5EFdGK5FFfylfyY8ie7vY4viOS8ZZRjaspsiz8)
What could I be doing wrong?
![image](https://private-user-images.githubusercontent.com/9842243/281411559-22d56853-d4fd-404a-a4ca-7727b33e3606.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NjQ2ODUsIm5iZiI6MTcyNDc2NDM4NSwicGF0aCI6Ii85ODQyMjQzLzI4MTQxMTU1OS0yMmQ1Njg1My1kNGZkLTQwNGEtYTRjYS03NzI3YjMzZTM2MDYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMTMxMzA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTM2NjYzN2YxNjc4YTE0YmEyNWYwNzk4ZjEzNzM4YzM3OWFhZGZmODQwY2MyZjZhOThlZDBkNzQ3MTgxNzI3MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.2ZrK28MUjsPzAabbr1nqx_F9-Et0XzyrBw-ucHudEcw)
Beta Was this translation helpful? Give feedback.
All reactions