Files
redux-form/docs/ValueLifecycle.md
Kevin Huang 1c6ac42d01 Fix broken links & image in documentation (#1651)
* Fix broken link to proptypes.js in props documentation

* Fix broken link to reduxForm() api docs in the props api docs

* Fix image source url for life cycle page in the docs

* Redo fix for ValueLifecycle image source with better raw github url
2016-08-30 08:12:34 +02:00

1.2 KiB

Understanding Field Value Lifecycle

It's important to understand how your field value is flowing through redux-form.

Value Lifecycle Hooks

redux-form provides three value lifecycle hooks, provided as props to the Field component. They are all optional.

format(value:Any) => String

Formats the value from the Redux store to be used for your input component. Common use cases are for maintaining data as Numbers or Dates in the store, but formatting them a specific way in your input.

parse(value:String) => Any

Parses a string input by the user into the data type that you want to use in the Redux store. Common use cases are for maintaining data as Numbers or Dates in the store.

normalize(value:Any, previousValue:Any, allValues:Object, previousAllValues:Object) => Any

Allows you to add logic based on all your form values to put a constraint on the value of the current field. Common use cases include making sure that minDate is before maxDate. If you have provided a parser, the value given to normalize() will already be parsed.

Value Lifecycle