1
votes
handleDeleteClick = propertyName => () => {
  this.props.clearFilterOption(propertyName, this.props.filtersPropertyName);
  this.props.onFilterClear();
};

handleDeleteClick function is a button handler. My first redux action clearFilterOption modifies the store. The second action onFilterClear is the asynchronous action that maps filter params from redux-thunk's getState and calls api. My question is - does redux thunk wait for earlier dispatched action that modifies the store? In other words - do I have a certainty that the second action will fire with the most recent store version?

For now it works as expected. The second action fires with cleared filter option. But I don't know if it's because I'm using redux-thunk, or because clearFilterOption for now, is a low cost function.

1

1 Answers

1
votes

The Thunk middleware doesn't 'wait' as such, all it does is looks at the action that's been dispatched, and if it's a function it calls it.

The order that your store is modified is governed by your actions and whether they're asynchronous or not.

In your case, if your first action clearFilterOption is synchronous then it will always update the store before the second action is dispatched. If it isn't synchronous then it depends on the timings of whatever is happening within your Thunks.

If you always need one thing to occur before the other you should chain your actions (as Thunks) rather than dispatching them sequentially in your handleDeleteClick.