when I start a new project I always need to use a boilerplate with redux, redux saga, redux persist (or whatever I need) or to look at some old project I did because I never remember how to do that.
Is that normal or it's just me? Did you find any "solution"?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (7)
Check out the official Redux Toolkit or easy-peasy to reduce the need for boilerplate.
And there's always the option of not using Redux. Constate, Zustand, react-tracked, or just plain context (make sure you're colocating context providers, not just doing it all top level, and/or using something like @dai_shi 's implementation of useContextSelector) and hooks can be excellent state management solutions. You'll still need to implement persistence, but there are even solutions out there to use Redux middleware (such as redux-persist) with e.g. useReducer.
While many are now saying that remote state should only be thought of as cache in the frontend app, it's also entirely possible to use something like Firebase, AWS AppSync, Apollo, or the excellent RxDB (wrapper around RxJS and PouchDB, with optional GraphQL sync via two simple mutations, rather than the CouchDB replication protocol) as state management solutions with persistence and sync built in.
From my experience, it gets easier the more times you manually implement it. After I first learned how to use Redux, I wrote a blog post on the subject which forced me to do the whole set up from scratch again to make an example of the process.
If I still need help in a future project, I will just look back at what I wrote there.
I mean, it's bad not Remembering how to implement It? In One of my First interview I was asked to make a stupid project in which I needed redux and I had to look at how to do that
No. Its not just you. I've learnt React and Redux on my own for personal projects. And I've always had hard time remembering what I did with Redux whenever I go back to my old projects and have to relearn every time. I get the concept of uni-directional flow of data using pure functions and a store. But the code is split into so many pieces, that sometimes its hard to keep track of all of it. Also, "reducer" is such a terrible name for such an important concept. Anyway, TL;DR, I moved to Resub and I'll never look back. It is much easier to understand and retain in the head.
what is resub?
Resub is Microsoft's answer to Redux. I personally use it for my projects and it is very simple to use. You can look at the examples in the github repo to get started. It does require typescript though.
Not just you. I think it's something that will become easier with time. Like they say repetition is the key.