I am trying to clear specific Field value in Redux-form, I tried but I am failed because I am new to React and redux. Could someone please tell me how to clear specific field value?
Code
<div className="space-2">
<Field
name="firstName"
component={renderField}
type="text"
label="First Name"
validate={isFieldRequired}
/>
</div>
<div className="space-2">
<Field
name="lastName"
component={renderField}
type="text"
label="Last Name"
validate={isFieldRequired}
/>
</div>
<div className="space-2">
<Field
name="email"
component={renderField}
type="email"
label="Email Address"
validate={isFieldRequired}
/>
</div>
If you are using redux form then do it in the following ways:
import { change } from 'redux-form';
// write a function as below
fireFieldValueChange() {
this.props.changeValue('loginForm', 'email', '');
}
// in your mapDispatchToProps
changeValue: (form, field, value) => dispatch(change(formName, fieldName, valueToBeSet)),
Hope, this helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.