| This isn't a solved problem. The React ecosystem has spent the last few years trying a model where the application layer separated from the view layer with a pure functional state management solution called Redux. The overwhelming response? People didn't like it. Decoupling systems is a trade-off. Pull your network requests out of your components and you have two bits of code that are easier to test. Indirectly, the component is still going to call that code, and it's up to you to manage the complexity of that indirection. Not every application needs separation of concerns, and in many, colocation of concerns reduces the cognitive burden, because you can reason about components in isolation. To me, that's a more powerful guarantee than a function being strictly pure. |
Redux is still by far the most widely used state management tool with React apps (my estimates are around 45-50% of React apps use Redux), and we try to give clear guidance in our docs on when it does and doesn't make sense to use Redux.
FWIW, we get highly positive feedback on a daily basis from users who tell us how much they love using Redux Toolkit.
Resources:
- https://blog.isquaredsoftware.com/2018/03/redux-not-dead-yet...
- https://blog.isquaredsoftware.com/2021/01/context-redux-diff...
- https://blog.isquaredsoftware.com/2021/05/state-of-redux-may...
- https://blog.isquaredsoftware.com/2021/05/learn-modern-redux...
- https://blog.isquaredsoftware.com/2017/05/idiomatic-redux-ta...
- https://redux.js.org/tutorials/index
- https://redux.js.org/tutorials/essentials/part-2-app-structu...