javascript - 如何发送 redux-form 数据
问题描述
我有登录组件。这里我使用了 redux-form。由于我是新手,您能帮忙从 redux-form 获取表单数据(如何提交表单数据)吗?
<form onSubmit={this.onSubmit}>
<div className="padding5">
<Field name="email" type="email" component={RenderField} label="Email Id" />
</div>
<div className="padding5">
<Field name="Password" type="Password" component={RenderField} label="Password" />
</div>
<div className='buttonSection'>
<button type="submit" disabled={this.state.errors} className='buttonField padding5'>Reset Password</button>
</div>
</form>
解决方案
你的代码看起来不错。您必须使用Form
from redux-form
:
import { reduxForm, Form } from 'redux-form';
// Your form component
<Form onSubmit={this.onSubmit}>
// Your form
</Form>
确保您已添加redux-form
到您的 redux 商店:
import { combineReducers } from 'redux';
import { reducer as formReducer } from 'redux-form';
const combinedReducers = combineReducers({
form: formReducer
})
并且您正在导出包装好的表单:
import { reduxForm, Form } from 'redux-form';
// Your form
export default reduxForm({
form: 'name-of-form'
})(MyForm);
推荐阅读
- java - Java - 如何在 switch 语句中调用方法?
- c# - 命名空间“System.Web”中不存在类型或命名空间名称“Script”(您是否缺少程序集引用?)
- django - 无法在 django 表单提交时将值插入数据库
- sql - 更新我的触发器以进行多行插入、更新和删除?
- macos - 前向引用 (_telldir)
- javascript - 我需要使用 contructor 对象在 console.log 中显示对象的完整名称(姓名和姓氏)
- android - 发现多个文件具有独立于操作系统的路径“AndroidManifest.xml”
- r - R中是否有一个函数可以提取所有可用的包和函数
- c# - 无效的参数绑定\r\n参数名称: System.DateTime 上传数据到 oracle 表时
- c# - linkedList.find() 中的意外 gc 分配行为