输入值当我具有先前的值时不会更改
我有一个文章字段组件,该组件加载文章对象(通过location.state),它具有空的参数(当我尝试制作新文章时)或 preexisting值当我想编辑文章时。my输入,当我传递先前存在的值时,也不会更改,即使它是一个空字符串。另一个手,on Change函数仍然适用于textarea 。任何关于这种情况发生的想法,我知道我可以将输入更改为textareas,但是我想了解为什么首先发生这种情况
是用于参考的沙箱
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用DefaultValue而不是值:
Use defaultValue instead of value: