Where is the sensible place to modify response data in redux?
As for me I do this kind of things in the action (either coursesLoaded
or fetchData
).
Here are the reasons why:
- This is not store material, this is just external data management, so nothing to do with reducers which are supposed to change the STATE of the store
- Different reducers might actually need the same corrected data, imagine you have another reducer that gathers all
additionalProperty
for achiving purposes for example, so doing it in the action ensures that the right data is sent to all reducers. - This is not a typical job for a middleware, this is only specific to one action, whereas middleware would be useful if it was used the same way by a bunch of actions. Plus using middleware is more obscure and separates it from the reader. Having action-> reducer is much more simple and does not have any major disadvantage.