The State of State Management in React

preview_player
Показать описание
I discuss how I like to approach state in React and what my thoughts on Redux, Recoil, and React Context are.

----
Checkout my side projects:

----

----

----
Follow Me Online Here:


----
#benawad
Рекомендации по теме
Комментарии
Автор

Dan Abramov made a tweet saying Ben shouldn't bash Angular, so Ben decided to take revenge with Redux :D

vasilstoyanov
Автор

This is my biggest beef with React. No one knows what the hell to use. Analysis paralysis and "library fatigue" are serious problems.

joshblf
Автор

last time i was this early, ben was still hating on angular

akshitkumar
Автор

Just store everything in a variable and you're fine.

Keeqler
Автор

Having used Recoil in both small and large applications I can say that it is very useful in both spaces. Recoil is simple to understand, setup and requires no boilerplate to get started. State and hooks are simple.

This in contrast with something like Context, which would require you to setup contexts for each slice of state you need, and likely provide some helpers (e.g. hooks) to easily consume the context.

That said, Context is useful for a lot of things where you may have a lot of logic and custom behavior, specific for your problem space. Using Context in larger applications has multiple pitfalls which can hurt the maintainability of your app. For example, you end up with a provider-soup in some parts of your app. You need to manually apply optimisations to prevent regressions which can slow down the app (which again, could mean more provider-soup).

I am working in a team of two for a semi-large app, and we currently don't use any third-party state management libraries. Just local state or contexts, and we are at a point where it makes sense for use to find a better solution to manage state in a more and more complex application.

dealloc
Автор

there is a state library named zustand? haha cool :)

I wish could have hair problems like Ben has 🙄

wcandillon
Автор

BEN you are one hell of a guy. Love this

IbrahimJoseph
Автор

One thing I like about Recoil is that it's coming from Facebook. If they also open source Stylex, their CSS in JS solution it means that we might get an "official" implementation of these two things. This is something that is missing in React, official way to do these few common things like styling, state management and maybe routing. I like the fact that React is heavily unopinionated, but having few of these libraries as official libraries would definitely be helpful.

But who knows, maybe the fact that Facebook didn't offer bunch of stuff out of the box made the community grow to this level.

randmtv
Автор

The sheer amount of tutorials that are on most react courses online about redux are insane, earlier i thought redux is specifically for react, I find most of the time I am okay with context and useReducers unless it is a giant e-commerce app or something.

sagarprasad
Автор

I typed the URL and got my answer! Thanks man, well done!

casual_sky
Автор

state in React became so cluttered that I just architecture better my apps to share state, passing down props is okay, using context is okay as well.

alexfvcruz
Автор

Hey Ben

Wonder what do you think about MOBX for state management?

omergronich
Автор

“Cross reference against some if statements...” made my year 😅

draysams
Автор

Now in 2021, I simply found my absolute comfort zone with simple tiny libraries that are simple as hell. I just use "Simpler State" (simply look it up and you'll see what I mean). >>Was using Easy Peasy before, also good. Tried Recoil, not what i need.<<

robovirtuoso
Автор

We heavily use redux at work, i don't use it for async actions but we use it for state e.g. Setting a home gym from a completely seperate headless page. I don't like it, but it works well.

alexmachin
Автор

Just love you videos man super entertaining and educational at the same time keep up the good work!

lloyd_jvr
Автор

That link sends you to Never gonna give you up lmaooo

thearyaman
Автор

I’ve been using React Context for my social media app as well with Asyncstorage - totally would recommend it, made my life 20 times easier

anatolypash
Автор

Nice one Ben. I like the fact that you're gradually opening-up

simonkalu
Автор

04:25 what is the state management library that Ben mentions here? Edited: Ooops just looked at the right hand video Zustand - will try it soon.
As for Redux, , I've been doing React for 3+ years and indeed I haven't touched that over-engineered library until now and I am getting by just fine without it. Just like Angular-JS, I've made the conscious decision to skip anything Angular; just like Silverlight, when microsoft pulled the rug from under everyone. lol

joe-sydney-au