Home > Mobile >  Input value not changing when i have preexisting value
Input value not changing when i have preexisting value

Time:07-05

I have an ArticleFields component that loads an article object (through location.state) which has either empty parameters(when i try to make a new article) or preexisting values when i want to edit an article.My inputs though, won't change when i pass a preexisting value,even if it's an empty string.On the other hand ,the onChange function still works for textarea.Any ideas to why is this happening,i know i can just change the inputs to textareas,but ofcourse i want to understand why this is happening first

Here is a sandbox for reference

https://codesandbox.io/s/green-sound-sopdvp?file=/src/App.js

CodePudding user response:

Use defaultValue instead of value:

value={article.title}
  • Related