我试图在react js中做一些表单验证,而使用redux表单面临一个错误字段必须在用reduxForm()修饰的组件内.我刚刚在网上搜索了这个错误,但没有得到任何解决方案.参考链接:http://redux-form.com/6.8.0/examples/simple/.这是我的代码,
import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
export class EditProfile extends Component {
render() {
console.log("hello welcome");
const { handleSubmit, pristine, reset, submitting } = this.props;
return (
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="firstName">First Name</label>
<Field name="firstName" component="input" type="text"/>
</div>
</form>
);
}
}
export default reduxForm({
form: 'editForm'
})(EditProfile)Run Code Online (Sandbox Code Playgroud)
我在代码中做错了,有人可以澄清我.