react-redux-form
react-redux-form copied to clipboard
Update onBlur only if value has changed.
I have the following instance of Control:
<Control.text
placeholder="optional"
model=".username"
id="username"
updateOn="blur"
changeAction={this.changeAction(order._id, 'username')}
/>
Then I have the following changeAction:
changeAction(id: string, property: string) {
return (model: string, value: string | number) => {
this.props.updateField(id, property, model, value);
};
}
This works great but it means that it calls the updateField function (connected to db) everytime the field blurs even if the value hasn't changed.
Does RRF support checking if the field is dirty? I see the pristine field inside of my state for the form field but I'm not sure what the best way of checking it is. In my state it is located at rrf.forms.orders[0].username.pristine
but I feel like there should be a function for checking this so I don't have to reference the orders index directly inside the state.
+1