A set of utilities for working with redux-form
.
npm install --save qc-redux-form_utils
or
yarn add qc-redux-form_utils
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)