redux-form-immutablejs-example

0.1.0 • Public • Published

redux-form with immutablejs example

Shows how to use redux-form with a store that uses an immutable object as the state object in the store.

Key parts

Using the getFormState option to the reduxForm decorator to transform the immutable state to a JS object

@reduxForm({
  form:'simple',
  fields:['firstName'],
  getFormState: (state, reduxMountPoint) => state.get(reduxMountPoint).toJS()
})

Wrapping the form reducer in a function to transform the form state into an immutable object.

import {reducer as formReducer} from 'redux-form';

export const form = function (state, action) {
  return Immutable.fromJS(formReducer(state, action));
}

Using

git clone https://github.com/itaylor/redux-form-immutablejs-example.git
cd redux-form-immutablejs-example
npm install
npm start

Then open http://localhost:3000

Implementation quirks

This uses the babel-plugin-transform-decorators-legacy to get decorator support in babel 6.

Readme

Keywords

none

Package Sidebar

Install

npm i redux-form-immutablejs-example

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • itaylor