diegohaz / arc

React starter kit based on Atomic Design
https://arc.js.org
2.91k stars 295 forks source link

[redux] Does Redux Form need sagas to return new SubmissionError? #307

Closed steven-haddix closed 7 years ago

steven-haddix commented 7 years ago

So I was messing around with using redux form in a new project and was curious why I couldn't get back the general error field ("_error") while using the _FAILURE actions.

I added the following in my sagas and the errors began returning: yield put(actions.authLoginFailure(new SubmissionError({ _error: e.message }), request, thunk))

Does anyone know if this is best practice?

diegohaz commented 7 years ago

I would keep it out of sagas.

Something like this (on container):

const onSubmit = (data, dispatch) => (
  dispatch(resourceCreateRequest('posts', data))
    .then(...)
    .catch((e) => {
      throw new SubmissionError({ _error: e.message })
    })
)