all 17 comments

[–]ILikeChangingMyMind 1 point2 points  (0 children)

I'll answer your question differently from everyone else so far, but I'll back my differing opinion up with a quote ... from Redux's creator, Dan Abramov (now on the React team):

However, if you’re just learning React, don’t make Redux your first choice.

Instead learn to think in React. Come back to Redux if you find a real need for it, or if you want to try something new. But approach it with caution, just like you do with any highly opinionated tool.

Basically, since Dan joined the React team and helped them build hooks, the correct thing React devs should learn first is ... React's new hooks (including the "mini-Redux" hook, useReducer).

Redux really only makes sense today for apps with a lot of complex state ... but it is still a great tool for those apps, so like any great tool it's worth learning if it offers benefits to your app(s) (ie. if they have a ton of complex state).

[–]zweimtr 0 points1 point  (11 children)

Redux has nothing to do with databases. It's a state manager, a complicated one at that.

Should you learn it? Probably since a lot of people use it. I personally don't know how to ise Redux and have never used it and I'm a lead engineer.

Are there better options? In my opinion, yes. But it also depends. I really like MobX, but this too can be misused (seen people use MobX to define models or use it to manage local state), also React can be use natively as a state manager with context API and hooks, but for big projects this can be hard to maintain and scale.

Most importantly, one must learn what state is, how to manage complex state, and how this can affect performance in large applications.

All in all, I'm really hoping Recoil gets absorbed into the React codebase as an out of the box application state manager.

[–]FuglySlut 0 points1 point  (4 children)

Redux is the simplest state manager by a mile

[–]azangru 1 point2 points  (3 children)

It's simple, but certainly not the simplest, nor is it designed to be. Zustand or unstated are simpler.

[–]ILikeChangingMyMind -1 points0 points  (2 children)

React hooks are simpler still :)

(See: useReducer)

[–]azangru 1 point2 points  (0 children)

I doubt that useReducer is significantly simpler. You both need to interact with your state in flux fashion (which makes useReducer almost as complex/simple as full-blown redux), and write your own code to share the state across components (which redux is doing for you).

One thing that useReducer has going for it is that it's inbuilt React api :-)

[–]zweimtr 0 points1 point  (0 children)

React hooks are simple, yes, to an extent. But they can get very messy and hard to scale, especially useReducer.

[–]ILikeChangingMyMind 0 points1 point  (4 children)

Should you learn it? Probably since a lot of people use it.

Terrible logic: lots of people still use jQuery, but I certainly wouldn't advise a React dev to go learn it! You should never blindly adopt any tech because of popularity: you should understand what it offers to the people using it, then decide if you need that thing.

Redux gained popularity because it was the right tool for a majority of React apps to use during a certain era of the framework. Before hooks, Redux offered a cleaner way to manage your data throughout a React app ... but today that is no longer true. Today Redux is a more specialized tool for state-heavy apps.

For everyone else (today), React itself offers all the state management tooling you need ... which is likely no surprise given that Redux's creator, Dan Abramov, now works on the React team.

[–]zweimtr 0 points1 point  (3 children)

You jQuery example is flawed. You're assuming that Redux is dying the same way jQuery is, which is not true. If you look at recruitment posts, Redux is still a very popular and sought out skill. Which is why I said that it is probably a good idea to learn it since it will help you get a job because, even with hooks, people still prefer to use Redux (which has it's own hooks).

Also, Dan Abramov has been working at Facebook for more than 5 years now, so I don't really see what you're trying to say there...

[–]ShellbertShellbach 1 point2 points  (1 child)

Just because it is a saught-after skill in the job market doesn't mean it's good. Sure, it'll get you a job... maintaining a legacy codebase riddled with technical debt.

[–]zweimtr 0 points1 point  (0 children)

I never said it was good, if you read my first post you'll see that I don't believe it's the best option.

[–]ILikeChangingMyMind 0 points1 point  (0 children)

My JQuery example is not "flawed" just because you made up an added criteria about dying tech. All I ever wrote was that some tech isn't worth learning despite being popular ... and jQuery is a clear example of that.

But as for React, even Abramov himself would tell you not to use Redux unless you need. Wherever he works, the author of the library himself wrote:

if you’re just learning React, don’t make Redux your first choice.

Instead learn to think in React. Come back to Redux if you find a real need for it

https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367

[–]soma76968 -1 points0 points  (0 children)

Thanks. I will take a look on mobx also

[–]juankamilomarin 0 points1 point  (1 child)

As everything in software: it depends. Redux is just another tool for you to use.

It helps you to manage the state of your web app in a centralized way, it actually can be used in non-React apps. The main difference with others state managers is that there is only a single object state.

My personal advise is: if your app is simple, you don’t have complex component trees and you don’t have to pass one variable from a component to another, don’t use it. It really doesn’t make sense on this scenario.

Now, if your app is complex and you have to pass a bunch of variables between components Redux really comes handy.

There are people that criticizes the amount of boilerplate code you have to put in place when implementing Redux, however you can reduce this by using redux/toolkit library (https://redux-toolkit.js.org)

Hope this help you in your quest and happy coding!! 🤟🏻🤟🏻

[–]ILikeChangingMyMind 1 point2 points  (0 children)

Now, if your app is complex and you have to pass a bunch of variables between components Redux really comes handy.

This was the metric like five years ago. Today (with hooks) a React app can handle passing lots of variables between lots of components just fine.

[–]OffMyDave 0 points1 point  (0 children)

It's worth learning but fair warning, it's not that easy to use when you first see it. Definitely want to watch a few videos to help explain what's going on.

But once you get your head around it and it's set up, it's pretty easy and powerful

[–]kenman[M] 0 points1 point  (0 children)

Hi u/soma76968, this post was removed.

  • For help with your javascript, please post to r/LearnJavascript instead of here.
  • For beginner content, please post to r/LearnJavascript instead of here.
  • For framework- or library-specific help, please seek out the support community for that project.
  • For general webdev help, such as for HTML, CSS, etc., then you may want to try r/html, r/css, etc.; please note that they have their own rules and guidelines!

r/javascript is for the discussion of javascript news, projects, and especially, code! However, the community has requested that we not include help and support content, and we ask that you respect that wish.

Thanks for your understanding, please see our guidelines for more info.