Reputation: 9195
How can I get the value of one field so that onChange I can set the value of a different field with redux-form in react?
<Field
fullWidth
name="FieldName"
component={renderTextField}
label="FieldLabel"
onChange={this.props.change('FieldNameAlt', 9999)}
/>
Instead of 9999, say I wanted it to be the value of FieldName*2
. How should I get the value of FieldName
to set the value of FieldNameAlt
?
Upvotes: 1
Views: 345
Reputation: 8023
If I understand correctly, you can get the value of the changed field by simply using the event
passed to the onChange
:
onChange={e => {
const val = e.target.value;
this.props.change('FieldNameAlt', val)
}};
Upvotes: 2