github redux-form/redux-form v0.4.0

latest releases: v8.3.10, v8.3.9, v8.3.8...
8 years ago

☑️ After a discussion with @gaearon on #17, and the great simplification that came with v0.3.0, I've decided to add an interface that will allow redux-form to do the react-redux connect() call for you. This is not a breaking change, and the old API will still work for the foreseeable future, but we now have a new API.

Migration Guide

This:

import {connect} from 'react-redux';
import reduxForm from 'redux-form';
...
// apply reduxForm() and include synchronous validation
ContactForm = reduxForm('contact', ['name', 'address', 'phone'], contactValidation)(ContactForm);

function mapStateToProps(state) {
  return { form: state.form };
}
// apply connect() to bind it to Redux state
ContactForm = connect(mapStateToProps)(ContactForm);

Becomes this:

import {connectReduxForm} from 'redux-form';
...
// apply connectReduxForm() and include synchronous validation
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation)(ContactForm);

Or, in ES7 land, this:

@connect(state => ({ form: state.form }))
@reduxForm('contact', ['name', 'address', 'phone'], contactValidation)
export default class ContactForm extends Component {

Becomes this:

@connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation)
export default class ContactForm extends Component {

Don't miss a new redux-form release

NewReleases is sending notifications on new releases.