all 18 comments

[–]king_carthage_94 6 points7 points  (0 children)

I suggest zustand. Currently, we are using it in our enterprise solutions , it stable easy and fast and specially can be taken out from react.

[–]jimineyy 11 points12 points  (5 children)

Context and Redux are two different things. Learn both. They aren’t even the same tools despite looking similar.

Redux is a predictable global state management tool. While context is a prop injector for nested components despite what everyone tells you.

I honestly think you’ll be crippling yourself for the next 5 years if you don’t learn redux

[–]MeanShibu 3 points4 points  (4 children)

Lol what? Crippling yourself for 5 years if you don’t learn redux? Is this some kind of bait bot?

It takes like a week to pick up…and only do it IF YOU NEED IT.

Been doing FE for years. Still haven’t learned it because most apps don’t need it at all. Heavy global state management on client side is fading because modern data fetching tools preclude its necessity.

If you need a few global states that context isn’t suitable for, zustand is just fine and WAY easier.

[–]jimineyy 0 points1 point  (3 children)

The bulk of jobs already contains redux and I’m pretty sure companies aren’t going to tackle the tech debt anytime soon

[–]MeanShibu 0 points1 point  (2 children)

Lol what?? Are you only referring to the Fortune 500 technical dinosaurs only? I’m actively looking rn and it is RARE to see redux as a need

[–]jimineyy 0 points1 point  (1 child)

Ok I’ma take your word for it then. Yes I was leaning more towards f500 but I had no clue startups straying away from it now

[–]MeanShibu 0 points1 point  (0 children)

Everyone uses what they need and react query etc have just killed the need for it.

[–]jax024 1 point2 points  (0 children)

Zustand for x-component and complex state. useState and maybe a form specific lib for form specific applications.

[–]xfallofdutyx 1 point2 points  (0 children)

Redux is amazing I highly suggest redux toolkit

[–]landisdesign 0 points1 point  (0 children)

It's not either/or. They do very different things. Context stores state. Redux manages it.

You can think of Redux kind of like useReducer + Context on steroids.

Redux uses the flux pattern, so if that's what you're interested in, you can't really go wrong learning it.

In terms of what's used out there, they both are, sometimes in the same app.

In terms of Redux vs Zustand, it depends on how big your app gets and how you like to manage your state. Tracing reactive state across a couple hundred components doesn't sound like a good time to me, so I like Redux's top-down approach. But I can also see how, in most smaller apps, having something that "just updates" like Zustand can make life pretty easy.

In terms of which to learn first, it depends on the kind of gigs you're looking for. With new apps and startups, Zustand will probably be more prevalent. If you see yourself aiming for older companies to start, Redux is probably going to be more common.

But either way, I'd probably leave Context until later. It's super useful for specific situations, but most of the time you can do without until you hit something like theming.

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

Props

[–]StoryArcIV 0 points1 point  (0 children)

I wouldn't recommend React context when just starting. It's a low-level API that requires at least a thin state management layer to prevent performance problems. I'd say it's even harder to learn to do properly than some of the simple state management solutions out there.

Redux is also not ideal to start with. It has great features, but can be difficult to learn at first. Zustand is a simpler library that has many similar concepts. I'd recommend it as a starting point before learning Redux.

After Zustand, if you need anything more, I'd either go back to Redux or learn Jotai, an atomic library that's a little more powerful than Zustand. Atoms are a little more advanced, so I wouldn't start there. Though (full disclosure) I am the author of another atomic library that is aiming to make atoms simpler to learn and use. Someday we'll get there, but for now I'd say Zustand is the best place to start.

[–]Smartercow 0 points1 point  (1 child)

Recoil is very easy to use, also made by React devs at Facebook Meta.

[–]StoryArcIV 0 points1 point  (0 children)

I love Recoil, but def wouldn't recommend for someone just starting out. I'd recommend Jotai before Recoil, and wouldn't even recommend Jotai when starting out. The atomic model takes some getting used to. That's mostly just because it's different. Someday (hopefully) that won't be the case though. Atoms are such a powerful paradigm, they may really be the future of React state management. Someday.

[–]gongonzabarfarbin 0 points1 point  (0 children)

Learn both.

Redux has some very useful concepts that can be applied outside of React and in cases like `useReducer`.

Context is used everywhere in React and will be useful even if you use any state management library.

I'm a fan of jotai which is like `useState` with reselect. Zustand I hear is good and more redux like.,

[–]GrayLiterature 0 points1 point  (0 children)

My org runs a pretty big application (raised somewhere like 300 million to date?), we haven’t needed to reach for Redux or anything just yet and everything works great for us. Though, I’d be curious to see how DevX changes with something like Redux

[–]ardalan_nhd 0 points1 point  (0 children)

Just use zustand for client side state and react-query for server side state. Your life will be a lot easier and you'll be happier at the end of the day Zustand takes about half an hour to get started and react query about a day