Redux-form: Passing options to onSubmit?

Created on 27 Mar 2016  路  2Comments  路  Source: redux-form/redux-form

Hi

I have a form where the user can either 'Send' or 'Send & Archive' a conversation.

I was to bind an 'archive' flag to the onSubmit callback when the user clicks the Send & Archive, but the parameters are overwritten by the formvalues provided by ReduxForm

How can this be accomplished?

question

Most helpful comment

How's this?

const makeSender = archive =>
  (values, dispatch) => {
    dispatch(send({
      ...values,
      archive
    }))
  }
}

<button onClick={handleSubmit(makeSender(false))}>Send</button>
<button onClick={handleSubmit(makeSender(true))}>Send & Archive</button>

All 2 comments

How's this?

const makeSender = archive =>
  (values, dispatch) => {
    dispatch(send({
      ...values,
      archive
    }))
  }
}

<button onClick={handleSubmit(makeSender(false))}>Send</button>
<button onClick={handleSubmit(makeSender(true))}>Send & Archive</button>

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

menesh2 picture menesh2  路  43Comments

rluiten picture rluiten  路  54Comments

albermav picture albermav  路  38Comments

alexw668 picture alexw668  路  48Comments

erikras picture erikras  路  85Comments