Search code examples
reactjsreduxredux-form

Redux-From getFormValues() returning undefined when values are in Fields


I need to use the values from state to make dynamic fields appear.

I have the below code:

{jobSpec &&
this.renderRows(form, form.dependencies.jobSpec[jobSpec[0].id])}

const mapStateToProps = (state) => ({
    formData: state.formData,
 
    jobSpec: selector(state, 'jobSpec'),

    values: getFormValues('formWizard')(state),
  });

The field named jobSpec causes more fields to load depending on what the value is, in the first part of the code.

The forms will be created with JSON and I will not know that names of all fields or their values, so I need to loop through the values in state and check if a new field should be loaded whenever state changes.

I added getFormValues() to get the values on the form. However Values are always undefined no matter what I enter into the form fields.

So either this function is not being called or it's not updating with state change.

Does anyone have experience with this?


Solution

  • Well it appears that "values" is being used elsewhere. When I change it to:

    formValues: getFormValues('formWizard')(state),
    

    The issue was resolved.