Redux is one of the widely used State Management Solutions in React Applications. Even though it has several upsides, one major pain while working ...
For further actions, you may consider blocking this person and/or reporting abuse
How about redux-toolkit?
I was here to mention Redux-toolkit
It further simplifies everything and the boilerplate code you write is very small and simple
I actually have a custom hook that does exactly what's in this article but in a much more simple way and it is using redux-toolkit
It also greatly improves async data fetching when you aren't using something like react-query. It provides useSelect and useDispatch as hooks, making things very easy, maybe the async set up could be improved, but after you understand its mechanics it makes sense. Start by their guides on the official website, I guarantee you will like it 😁
Could you please share it? It would help out the readers a lot
Yes, a lot of people had been using it lately. I haven't used it yet, so I don't have enough experience to comment on it
So the next-gen react-redux is actually
zustand
? Didn't expect they'd copy the API of it but that's the fun part of open-source. But at least it'd take fewer boilerplatesIts quite similar, yet different from
zustand
.Ps: I don't know much about
zustand
, I looked through how it's used and drawing conclusion from thatOf course, they don't work similarly
zustand
is much more flexible, simple & atomic. FYI, it doesn't have the zombie-child/stale-props issue tooIt's a great state manager for simplicity in your codebase
Great! I'll definitely look into it
This is pretty much as old as Zustand - it came out 2019, a few months after React hooks came out (after some fiddling they did to make sure that the api was good)
Was the performance difference actually tested? I don't think it has a signifficant difference using hooks or
connect()
. Of course, I can be wrong, and that's why having some results that prove this claim would be nice to see.I haven't tested it. I read some that the performance for both the approaches are at par with each other, but you can optimize the performance of
connect
a bit more than the optimization for the hooksJust use Recoil. I was a long time Redux user and then tried Recoil and I'm never going back. Recoil feels like it's part of React. Redux always needed so much unnecessary adapters, selectors, etc.. Recoil is fantastic.
The recommended way is to use RTK. It's even in the docs.
If you would like to have long term support for your React application use pure redux with redux-saga for managing side effects.