Cover image by Bryan Goff
To see the code for these examples, click here
There are seemingly endless ways of dealing with state management in R...
For further actions, you may consider blocking this person and/or reporting abuse
Note that we now specifically teach using our official Redux Toolkit package as the default syntax for writing Redux logic.
We have a new "Redux Essentials" core docs tutorial that builds a real-world app while teaching RTK as the standard way to use Redux, and I'm currently working on a new "Redux Fundamentals" docs tutorial that will teach the lower-level principles involved in using Redux, then finish by showing how and why to use RTK instead of writing Redux code by hand.
In this particular example, using RTK would keep the number of lines of code basically the same. Instead of this:
You'd have:
But, the difference in LOC between hand-written Redux and RTK becomes dramatically different as the app grows in size - RTK requires way fewer lines of code.
The updated tutorials should also make it a lot easier for people to learn Redux as well.
Hey Mark, thanks for the helpful update. I'll probably adjust my tutorial to use the most up to date implementation using Redux Toolkit. Nice work!!
Thanks for the quick article update! One bugfix: the package installation example is wrong - the package name is
@reduxjs/toolkit
:redux.js.org/introduction/installa...
Saved me, thank you!!
What do you think of RxJS based state management in React world? E.g. Akita or MiniRx Store?
I am working on MiniRx. It is like Redux but implemented with RxJS. State is exposed as an RxJS Observable. Observables integrate nicely with Angular. But not sure about React and Observables.
Thank you for writing the article!
I noticed two common mistakes with the context example, see my reaction to another article here: medium.com/@ewestra/great-article-...
Could you respond to the claim that Recoil is a context replacement, not necessarily a Redux replacement. I haven't used Recoil but have watched their videos. I am a Redux user.
Also, wouldn't it be fair to add GraphQL cache to this list as well?
Thanks.
Recoil is great but it's annoying that it doesn't work well with hot-reloading in development (have to manually refresh)
Awesome, such a nice to see you started with
recoil
:thumbGreat collection! Another nice solution would be Overmind by Codesandbox: overmindjs.org
Every time I see Redux those days. I am crying.
swr.vercel.app/
This library is not a state management per see. But I found sometimes I can get a long way with it.
I'd suggest looking in to unstated-next. It's based on context and React's state, handles async. It's dead simple and lightweight.
You miss the great Apollo Client, which is better than the others you mentioned (in general)
My favorite is state management library is zustand. It's very simple to use and flexible.