changing an uncontrolled input of type text to be controlled
2016-10-20 20:29
537 查看
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,即认为没有在可控数据范围类。。
原来我初始化的时候,未设置name值,
解决办法
1、formData 的值 formData.name="";
2、
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="请输入名称"/>
相关文章推荐
- Warning: Input is changing an uncontrolled input of type text to be controlled...
- keil(MDK)中出现error: #513: a value of type "int" cannot be assigned to an entity of type "char *",即函数返回值无法赋值给对应变量的错误
- Hint: This may be the result of an unspecified view, due to default view name generation.)]
- The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List
- caffe: fuck compile error again : error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
- 类似Build Error: #513: a value of type "int" cannot be assigned to an entity of type "char *"
- a value of type "const struct Menu * "cannot be assigned to an entity of type "struct Menu"
- How to solve the problem "A project with an Output Type of Class Library cannot be started directly "
- keil(MDK)中出现error: #513: a value of type "int" cannot be assigned to an entity of type "char *",即函数返
- mm_The type of the expression must be an array type but it resolved to List
- The type of the expression must be an array type but it resolved to Point
- Err:The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array
- Android学习系列第一弹之《warning:This text field does not specify an inputType or a hint》
- This text field does not specify an inputType or a hint
- android学习记录(This text field does not specify an inputType or a hint)
- Android开发报错:GoogleApiClient.isConnected()' was expected to be of type interface but instead was ...
- 关于opencv提取ORB特征时 cannot declare variable ‘orb’ to be of abstract type ‘cv::ORB问题
- android的main.xml文件中编写控件EditText时This text field does not specify an inputType or a hint
- new JSONObject(str)无法解析 报错:org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- textview cannot be resolved to a type 解决方法