redux-form#formValueSelector JavaScript Examples

The following examples show how to use redux-form#formValueSelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FieldSection.jsx    From covid19-testing with Apache License 2.0 6 votes vote down vote up
function mapStateToProps(state, ownProps) {
  if (!ownProps.section.conditions) {
    return {};
  }
  const selector = formValueSelector(ownProps.formName);
  const conditionKeys = ownProps.section.conditions.map((condition) => condition.field);

  const visibleFields = Object.keys(get(state, 'form.covidForm.registeredFields', {}));
  const visibleFieldValues = visibleFields.map((fieldName) => {
    return {[fieldName]: state.form.covidForm.values[fieldName]};
  });

  const formValues = Object.keys(get(state, 'form.covidForm.values', {}));

  return {
    formValues: selector(state, ownProps.section.slug, ...conditionKeys),
    visibleFieldValues: visibleFieldValues,
  };
}