我在我的React/Redux应用程序中使用了redux-form,我正在试图弄清楚如何在提交时发送一个动作.
我已经能够触发handleSubmit函数,并且我传递给它的submit函数被执行,但是没有调用'submitFormValues'动作.
我尝试过使用mapDispatchToProps和connect(),但这也不起作用.
Redux-Form操作执行(START_SUBMIT,STOP_SUBMIT,SET_SUBMIT_SUCCEEDED),但我自己的动作创建者永远不会执行.
这是表格:
import React from "react";
import { Field, reduxForm } from "redux-form";
import {submitFormValues} from "../../../actions/BasicFormActions";
function submit(values) {
//Can log the values to the console, but submitFormValues actionCreator does not appear to be dispatched.
return new Promise(function(resolve) { resolve(submitFormValues(values))} )
}
const renderField = ({ input, label, type, meta: {touched, error} }) => (
<div>
<label>{label}</label>
<div>
<input {...input} placeholder={label} type={type}/>
{touched && error && <span>{error}</span>}
</div>
</div>
)
const BasicForm = (props) => { …
Run Code Online (Sandbox Code Playgroud)