G'那天,我正在尝试做一些简单的事情,并且无法控制它。
我有很多表格。很多表格。为了使我的API在客户端上简洁,我想将两个状态值传递给我的客户端API。
import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import { Link, browserHistory } from 'react-router';
import { apiCreateData } from '../actions/api';
import { CREATE_PERSON } from '../actions/api';
import _ from 'lodash';
The apiCreateData is a generic client side API which needs to simply call a server API with the form contents, a TARGET URI of the server REST API, and a constant "which type of action is going on".
//------------------------------------
class CreatePeople extends Component {
//------------------
constructor(props) {
super(props);
this.state = {
target: 'add_person',
type: CREATE_PERSON
};
}
I can see these in my REACT tools in Chrome. The 'go' button calls this code.
//----------------------
onSubmit = (fields) => {
console.log('onSubmit');
console.log(fields);
this.props.apiCreateData(...this.state, fields).then(() => {
browserHistory.push('/');
});
}
我无法将这两位状态转换为客户端API中的接收道具。我尝试了很多东西!任何帮助赞赏。 欢呼声,
标记。