What I'm having makes me bang my head in the code, comparing it with the guidelines from mapStateToProps and Redux form. I'm trying to get a field value, but I'm continually receiving undefined. What I have is:
const myForm = reduxForm({
form: 'myForm',
})(MyComponentClass);
const mapStateToProps = ((state) => ({
l10n: l10nService,
formValues: getFormValues('myForm')(state),
}));
export default connect(mapStateToProps)(myForm);
When I try to output formValues like
console.log(formValues);
I'm getting constantly undefined. This is frustrating as I'm re-reading the docs and can't find where the problem is. I'm visualizing the field with a method like this:
addSelectFieldD(element, key) {
return (<Field
key={key}
name={element.name}
label={l10nService.translate(element.label)}
component={SelectField}
units={element.units}
options={this.props.selectOptions}
onChangeDuration={this.onChangeDuration}
onRetrieveSelectOptionsError={this.onRetrieveSelectOptionsError}
informationMessage={l10nService.translate(element.tooltip)}
submitted={this.state.formSubmitted}
/>);
}
Interesting thing is that I'm able to get formValues in some other component. I would highly appreciate any help guys as I'm so stacked with this.
EDIT: I've created an example here
console.log(formValues);
A Fiddle or codesandbox would be helpfull to understand the exact problem. - Miller