DEV Community

[Comment from a deleted post]
Collapse
 
veevidify profile image
V • Edited

Sounds like redux and thunk fits your use case. Thunk helps you organize your asynchronous API calls (dispatch actions to reducer after a Promise resolve your backend response).

The downsides (from my experience) so far are:

  • Setting up action/ reducer/ middleware takes a bit of work (once you're set up, writing actions and reducers become very simple).
  • You have to be careful about being too eager when mapping central state to components, especially when it is a large array; reducer's immutable pattern creates new array most of the time. From a glance, the article mentioned it and they used shouldComponentUpdate to block unnecessary re-render, and their use case is basic & clean. Ideally you want to avoid interfering with React component lifecycle with complicated logic, but if you need to do it, you gotta be very careful when creating conditions for it, otherwise you could end up with redux state and component rendered view out-of-sync all over the places.
Collapse
 
dylanesque profile image
Michael Caveney

This right here, if you need a central store that oversees state, that is literally one of the most useful features that Redux provides. There's definitely a learning curve, but it can really pay off in dividends once you get used to it.