redux-form返回动作数据无效形式

时间:2018-04-24 10:11:24

标签: reactjs react-redux redux-form redux-saga redux-actions

  1. 当我确认我的表单时,我的错误422包含数据:错误"表格无效"。
  2. 但是,我的操作会获取我的表单数据
  3. 但是,在通话结束后,请不要在我的api中发送我的数据。
  4. 如果有人有一个想法,我想更好地理解。
  5. 谢谢大家
  6. enter image description here enter image description here

    COMPONENT.JS

    array = [{name: 'name1', id: 1},{name: 'name2', id: 2}]
    
    <div *ngFor="let name of array">
        <p>Name: {{name.name}}</p> // Hard coded here (Name:)
    </div>
    

    ACTIONS.JS

     class CreatGroup extends React.Component{
    
     // function to post 
    
     handleFormSubmit = (dataForm) => {
     console.log(dataForm, ' DATA FORM')
     this.props.dispatch(createPostGroup(dataForm)) 
    }
    
    render() {
    // my form
    const { handleSubmit, submitting } = this.props
        return(
              <div>
                <form onSubmit={handleSubmit(this.handleFormSubmit)}>
                  <div>         
                    <Field name="amount" component={renderField} type="number" label="amount" />
                  </div>
                  <div>
                    <Field name="duration" component={renderField} type="number" label="duration" />
                  </div>
                  <div>
                    <Field name="limit_members" component={renderField} type="number" label="max members" />
                  </div>      
                  <div>
                    <button type="submit" disabled={submitting}>Submit</button>
                  </div>
                </form>
              </div>
            )
           } 
          }
    
          CreatGroup = reduxForm({
           form:'creat-group'
          })(CreatGroup)
    

    REDUCER.JS

        // CONST ACTIONS 
        const CREATE_GROUP = 'CREATE_GROUP'
    
        //ACTIONS
         export function createPostGroup(data){ return { type: CREATE_GROUP, data}};
    

    COMBINE REDUCER.JS

        // REDUCER 
        export default function groupReducer( state= {}, action){
        switch (action.type){
        case CREATE_GROUP:
            return action.data
        case CREATE_GROUP_FAIL:
            return {
                ...state
            }
        default:
            return state
          }
         }
    

    SAGAS.JS

    也许问题来自那里?

        // COMBINE REDUCER 
         const reducer = combineReducers({
          groupReducer,
          form: formReducer
         });
    

0 个答案:

没有答案