Search code examples
redux-form

Does redux-form change prop argument value as function work?


I have "redux-form": "^7.4.2". I see in the docs:

change(field:String, value:any) : Function Changes the value of a field in the Redux store. This is a bound action creator, so it returns nothing. You could get current field-value & form-values while value is a function, For example: change(field, (fieldValue, allValues) => {})

I try to do:

dispatch(
      change(formName, fieldName, (val, allValues) => {
        /* do something with arguments */
        return theResultOfTheAboveCode;
      }),
    );

It does not work. But the below code works fine:

dispatch(change(formName, fieldName, someValue));

Does the function as the value work?


Solution

  • You are using 7.4.2 which does not have the value as function.

    The docs are under https://redux-form.com/7.4.2/docs/api/props.md/

    The value as a function exists on the newest 8.x.x https://redux-form.com/8.1.0/docs/api/props.md/