So this means you put the business logic in the reducer? Or in some other middleware?
Jeremy Gerrits

Hi Jeremy,

Often, yes, I’ll use middleware for handling API Actions; You could also use Redux-Saga as an alternative.

For complex business logic, I’d recommend something like redux-saga or redux-loop or any of the other flow control libraries, keeping Redux just for state management; You can dispatch an action which isn’t actually reduced.

Typical business logic I see in action creators is stuff like talking to an API, or reading a bunch of state from the store and then dispatching an action with that state. (In the latter case, this is where my argument for a “redux-getstate” middleware comes in, that is, I think dispatching from a thunked action is the part that is wrong, not the getState call.)

Like what you read? Give Emelia Smith a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.