美文网首页
XXX is changing an uncontrolled

XXX is changing an uncontrolled

作者: 泉泉泉泉泉泉 | 来源:发表于2019-06-21 11:35 被阅读0次

app.bundle.js:9756 Warning: XXX is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components

问题分析:
React Input dom uncontrolled 导致报警告

问题解决:
主要是因为input的value值为undefined,未被赋值过,如下事例:

<input type="text" placeholder="请输入姓名" value={name} />

修改为:

<input type="text" placeholder="请输入姓名" value={name || ' '} />

相关文章

网友评论

      本文标题:XXX is changing an uncontrolled

      本文链接:https://www.haomeiwen.com/subject/stqyqctx.html