我正在尝试使用 redux-form 创建表单,但收到警告和错误,我无法纠正它。以下是这些警告和错误:
1.警告:标签上存在未知属性input
、meta
。从元素中删除这些 Prop 。
2.未捕获错误:输入是一个空元素标签,既不能有children
,也不能使用dangerouslySetInnerHTML
。检查绑定(bind)的createElement的render方法。
这是我的代码:
import React, { Component } from 'react';
import { reduxForm,Field } from 'redux-form';
const { DOM: { input, select, textarea } } = React;
class Createstudent extends Component {
render() {
const { handleSubmit } = this.props;
return (
<form onSubmit={handleSubmit}>
<div>
<label>First Name</label>
<Field name="firstName" component={input} type="text"/>
</div>
<div>
<label>Last Name</label>
<Field name="lastName" component={input} type="text"/>
</div>
<div>
<label>Email</label>
<Field name="email" component={input} type="email"/>
</div>
<button type="submit">Submit</button>
</form>
);
}
}
// Decorate the form component
Createstudent = reduxForm({
form: 'contact' // a unique name for this form
})(Createstudent);
export default Createstudent;
最佳答案
显然这是文档中的一个突出问题。当前打开的 github 问题如下:
https://github.com/erikras/redux-form/issues/1952
可以在这里找到正确的、更新的示例:
关于javascript - <input> 标记上出现警告 : Unknown props `input` , `meta`。从元素中删除这些 props,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42082108/