0

Facing a weird issue. I have an input field in my react app. I am setting the value of my input field using the defaultValue prop. But my input field is not populating. Its showing as empty ( "" ). But i can see the value in its value attribute in the dom. enter image description here

Here are the react props of that input

enter image description here

Any idea what i am missing here?

3
  • 2
    can you add html code in the question please? Commented Jan 22, 2018 at 17:56
  • May be try using 'value' instead of 'defaultValue' Commented Jan 22, 2018 at 18:02
  • How do you handle value of your input? Commented Jan 22, 2018 at 18:12

1 Answer 1

1

You could use defaultValue only on uncontrolled components, but your input have onChange prop, and that makes it controlled. You should set your default value through the value prop.

https://reactjs.org/docs/uncontrolled-components.html - here some info about it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.