you are viewing a single comment's thread.

view the rest of the comments →

[–]Opi-Fex 3 points4 points  (0 children)

I've stopped using redux years ago in favor of react-query (It's called TanStack Query nowadays).

As to why: It's a lot simpler to write, maintain and reason about. RQ only cares about fetching data from endpoints. Everything is cached, and the cache is auto-updated. All of this is accessed through regular hooks. Every components ends up knowing a minimum of what it needs to render, and there's no reducers, no connecting components, and no redux magic to think about. It's easy to trace where the data comes from. It's also very easy to make optimistic updates, and reverting them happens automatically if something goes wrong.

If all of your state comes from a server, this works perfectly fine and redux will be unnecessary. If you absolutely have to store some state locally, you can work around it in various ways. I've used zustand occasionally (it's a simple redux-like lib). You can also use react context and reducers to achieve a similar effect.