Skip to content

hypersoftllc/qc-redux-form_utils

Repository files navigation

qc-redux-form_utils

Build Status Coverage Status License Downloads

npm badge

A set of utilities for working with redux-form.

Installation

npm install --save qc-redux-form_utils

or

yarn add qc-redux-form_utils

Example Usage

import FormUtils from 'qc-dom_utils/form'
import { flattenErrors } from 'qc-redux-form_utils'
...

const FORM_NAME = 'MyForm'

class MyForm extends React.Component {
  ...
  render() {
    return (
      <form name={FORM_NAME} ...>
        ...
      </form>
    )
  }
  ...
}

const ReduxAwareForm = reduxForm({
  name: FORM_NAME,
  ...
  onSubmitFail: (errors, dispatch, submitError, props) => {
    let flattenedErrors = flattenErrors(errors)
    FormUtils.focusFirstInvalid(FORM_NAME, flattenedErrors)
  },
  ...
})(MyForm)