score:15

Accepted answer

Sagas do not stop actions from reaching the reducers. The saga middleware explicitly does the equivalent of:

next(action); // pass the action onwards to the reducers
processSagas(action);

So, the reducers will always see an action first, and the saga behavior will be excecuted after that.

The other issue is that it looks like you're trying to use the same action type to trigger the fetch behavior in the saga, and process the results in the reducer. I find that if you're using sagas, you generally have some actions that are "signals" meant to trigger saga behavior, and others that are intended to actually be handled by the reducers and update state. So, in your case, I would suggest using "FETCH_POSTS" as the signal to kick off the fetching, and have the saga then dispatch "FETCH_POSTS_SUCCESS" once the data is received and have the reducer respond to that action instead. (And, after noticing that you had that StackBlitz example up, I confirmed that just dispatching the results as "FETCH_POSTS_SUCCESS" does indeed work as I'd expect it too.)


Related Query

More Query from same tag