10
12 Comments

Is Redux still recommended in 2022?

https://www.reddit.com/r/reactjs/comments/pwfubd/is_redux_still_recommended_in_2021/
submitted this linkon July 6, 2022
  1. 2

    If you want to use redux, use redux toolkit ("rtk") (https://redux-toolkit.js.org)... all the benefits of redux streamlined to have minimal boilerplate.

    It's the official recommended way of using redux.

    I use rtk and love it.

    1. 1

      Or go one step further and use RTK Query to reduce the boilerplate even further

      1. 1

        Yeah, I think RTK Query looks pretty good. I'm not using it because I'm using Firebase Firestore queries which has like 99% of the functionality of RTK query built in. The only thing missing as far as I can tell is an "isLoading" state, but I don't want to wrap a Firestore query in an RTK query just for that.

  2. 1

    Highly recommend Recoil

    You can roll your own with useContext as well.

  3. 1

    I haven’t use it myself but friends of mine (who are real front-end developers) recommend adopting RecoilJS.

    It comes with a lot less boilerplate than Redux from what I’ve been told.

    For my business EnVsion we’re using Redux but I despair about the amount of boilerplate we write.

    1. 1

      Try https://redux-toolkit.js.org
      It's the official recommended way of using redux without the boilerplate.

  4. 1

    I like to use Jotai, it's simple, with no boilerplate, and it just works. It scales pretty well for big sites too.

    Redux has too much boilerplate, and too many steps and rules to make just the basics, even using other libs like redux-toolkit.

  5. 1

    I think redux has too much boilerplate and it can quickly become a mess. I personally use mobx since it's much cleaner.

  6. 1

    The real benefits of redux happen when your working in teams and everyone has to be able to read the codebase simply.

    I’d say a lot of projects it are doing so unnecessarily, especially when react query is out there and a far better substitute and less boilerplate.

  7. 1

    I've recently run into the issue of passing props up and down and I realized there was no escaping a state management package.

    The problem is: how do you know if you are going to need one or not based on the project?

    I didn't expect my project to get so large, and then it got too big and by then it felt like I was too late...I guess I can rebuild it using Redux but I just feel like it's better to move on and build something else.

    Either way, don't make the mistake I did. Use a state manager.

    1. 1

      Honestly, it feels like a lot of people are starting to use Context API for that problem, as the Redux maintainer mentions on the thread.

      Overall, the difference between Redux and Context API is massive. The two aren't substitutes for one another. Redux manage state side effects, i.e state responding to actions.

      If you end up using React Redux, context api I believe is used behind the scenes. But don't feel like you need to use it just because it's popular. There are millions of ways to code things, so you don't need to use it just because it's popular these days.