-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
Description
I'm in a situation where I'd like to dispatch two actions when a text box is blurred - I want to mark it as "touched" and also save it if there are no validation errors. I keep track of validation in the "change" reducer and only show the error message if a box has been "touched". I only want to save if there are no errors:
var item = this.props.items[index];
if (!item.error) {
this.actionCreators.saveItem(item.name, item.value);
}
this.actionCreators.touchItem(item.name);
I'm using API middleware similar to the Real World example. It doesn't seem right to dispatch multiple actions in a single event handler since the second action will be working with state that is out of date.
I feel like I'm missing something simple, as this seems to be a pretty common scenario.
Does anyone have recommendations?