menuAuth.js:1334 Warning: Form 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.
重点在这里:uncontrolled input of type text to be controlled
从没有被react控制到现在要控制,提示这个报错,
我们知道react是 数据---》视图
根据数据变化,使用虚拟dom找出变化的dom节点。然后最终更新。
那么这里为uncontrolled,即认为没有在可控数据范围类。。
<pre name="code" class="javascript"><input type="text" className="form-control" value={formData.name} placeholder="请输入名称"/>
原来我初始化的时候,未设置name值,
解决办法
1、formData 的值 formData.name="";
2、
<input type="text" className="form-control" value={formData.name||""} placeholder="请输入名称"/>