What State Management Library Should I Use with React?

  Рет қаралды 52,523

Lee Robinson

Lee Robinson

Күн бұрын

Do I need to use Redux? Should I just use React Context? This video will explain the past, present, and future of state management to help you make the correct decision for your team, project, or organization.
0:00 - Introduction
0:15 - History of React
0:50 - Flux Architecture
1:05 - Redux
1:31 - UI State
1:43 - Server Caching State
3:48 - Benefits of Separate Libraries
2:51 - React Context (useState / useReducer)
3:25 - State Management Today
3:41 - State Machines
4:17 - xState Demo
4:45 - Why are there so many state management libraries!?
5:52 - Immutable State
6:25 - Immer Demo
6:49 - URL State
7:33 - Performance issues with React Context
8:02 - useSelectedContext & Future
8:21 - State Management Suggestions
9:00 - Conclusion
Links
-----
leerob.io/blog/react-state-ma...
-----
Blog: leerob.io/
Twitter: / leeerob
GitHub: github.com/leerob
Course: react2025.com/
Gear / Coding Setup: leerob.io/uses
VSCode Theme: Sorcerer

Пікірлер: 81
@TheKurotsu
@TheKurotsu 3 жыл бұрын
My team and I just got a new project, and our team lead wanted us to make POC for different state management libraries. This video was extremely timely!
@pieter-venter
@pieter-venter 2 жыл бұрын
Thanks Lee for always having high quality videos with all the dense info in a very short time. I know it's not easy to edit a video like that and you probably need to repeat shooting parts multiple times. No "umm..." or "okay, let's wait for that to install"
@benmitchinson9831
@benmitchinson9831 3 жыл бұрын
Sent this video to a dozen devs. Great great explanation that I will be referencing for a long time.
@alvechy
@alvechy 3 жыл бұрын
Jumping straight to XState makes one David somewhere in the world smiling
@domsbuhendwa924
@domsbuhendwa924 3 жыл бұрын
Always great content Thank you for all
@vs599318026
@vs599318026 3 жыл бұрын
Such a great content but would like to see you create in depth videos for differnet state management lib or even intro to the upcoming useSelectedContext!
@aaaliii4u
@aaaliii4u 11 ай бұрын
now that is called awesome! thanks for the great tutorial and a taste of history.
@codersagora9837
@codersagora9837 3 жыл бұрын
Hey this video is really useful for our community, thanks!
@leerob
@leerob 3 жыл бұрын
Thank you! Glad you found it useful.
@kristiankramas5944
@kristiankramas5944 3 жыл бұрын
Wow. This was great.
@RickRyan26
@RickRyan26 3 жыл бұрын
Great vid!
@mikkaruru
@mikkaruru 2 жыл бұрын
Thanks Lee! What state management solution can be used for keeping global state of websocket data coming from IOT sensors to dashboard?
@geralt36
@geralt36 3 жыл бұрын
Using zustand and immer with typescript. Never enjoyed doing state management so much before.
@MightyKingKala
@MightyKingKala Жыл бұрын
Great video!
@mitejmadan8672
@mitejmadan8672 3 жыл бұрын
Thank you for creating this video. It really helped me to understand react and state. I didn't know about the types of states in an app. For the past couple of weeks, i have been working on a project which requires fetching a lot of data in my next app. basically I wanted to create a dashboard. I wanted to reduce unnecessary API calls. Today I got to know about SWR. I knew about react query but never knew what it does. This video literally summed up everything. I am watching your videos for the past couple of days they are really helpful
@leerob
@leerob 3 жыл бұрын
I really appreciate this comment. Glad I could help!
@yilmazbingol4838
@yilmazbingol4838 2 жыл бұрын
great explanation.
@moniruzzamansaikat4751
@moniruzzamansaikat4751 3 жыл бұрын
thanks for such a video
@ashishshinde7070
@ashishshinde7070 Жыл бұрын
Excellent👍
@roobannadarajah7989
@roobannadarajah7989 3 жыл бұрын
Who can dislike this. Cheers buddy
@frankybegue9492
@frankybegue9492 3 жыл бұрын
fantastic video. also appreciate the excellent bookmarking 👍
@Daniel-ve8yr
@Daniel-ve8yr 2 жыл бұрын
would you only use a caching library like SWR if you don't expect the API results to change in the short term? for example, if you're fetching stock quotes, i would imagine you don't want to used the cached result from 2 minutes ago.
@cheeriozkitty
@cheeriozkitty 3 жыл бұрын
This is the best video I've seen on this topic. Thank you so much for all of the great info here.
@RYeah100
@RYeah100 3 жыл бұрын
lol I said "it depends" in the same time haha, great video Lee thanks!
@aromal_anil
@aromal_anil 3 жыл бұрын
Every project don't need heavy libraries like Redux/Recoil. Sometimes you just needs to create and consume global states. "react-rhino" is a library which does exactly the same with simple and straight forward syntax. It uses Context API under the hood, but is very very simple than useContext.
@erickgeneric
@erickgeneric 3 жыл бұрын
Wow. I’m going to have to try swr 😳
@stej2248
@stej2248 Жыл бұрын
Hi, I am using pullstate which is very very easy while comparing all other global state management for react of redux, recoil, jotai etc. Is it good to use pullstate? Since I am a beginner i am finding difficult to choose the global state management.
@okidokiyowyow356
@okidokiyowyow356 3 жыл бұрын
Can I ask whats your react stack? Like what library do you use/like?
@robint457
@robint457 3 жыл бұрын
Great video as always! For form state management you didn't mention react-hook-form any thoughts on this?
@leerob
@leerob 3 жыл бұрын
I've made a video using it before, it's nice! Formik is just the most popular and widely used.
@robint457
@robint457 3 жыл бұрын
Didn't see it ... yet ;) Understand that you talk about the most popular one. It just seems to me that R-H-F is much easier to use and less boilerplate than formik. Anyway thanks for your answer and for the great content
@minhquanma
@minhquanma 2 жыл бұрын
thumbs up for Schiit Stack behind
@peteregbujie
@peteregbujie 3 жыл бұрын
use react query to manage your server state. redux and other libraries are not ideal to manage server state lifecycles. react query handles caching, fetching, and updates asynchronous data. if you remove all the server state from redux or other libraries to react query, your global state becomes very thin.
@dacks22
@dacks22 3 жыл бұрын
Your thoughts on zustand? Great vid Lee
@leerob
@leerob 3 жыл бұрын
Thank you! The Zustand authors seem to be recommending Valtio now: twitter.com/dai_shi/status/1358568517100920832
@rakeshpaul5691
@rakeshpaul5691 3 жыл бұрын
@@leerob didn’t know about Valtio. I was using zustand + immer for one of my projects. I also found recoiljs very similar to zustand
@user-kr6lp7rm5y
@user-kr6lp7rm5y 2 жыл бұрын
What library best for figma like app?
@ricardocoutinho6183
@ricardocoutinho6183 3 жыл бұрын
What do you think about recoilJs?
@leerob
@leerob 3 жыл бұрын
4:45 😁No strong opinion other than it works well for certain use cases.
@CodingNuggets
@CodingNuggets 3 жыл бұрын
For small projects Redux is not needed, but as a project grows it may become necessary. The Context API is great for side and small projects, but may not be enough. I use Redux mainly, but I'm starting to use react-query for my fun/side projects. Appreciate your input Lee. See you soon!
@onurbamaro
@onurbamaro 2 жыл бұрын
Client state: Hookstate Server state: React Query I've reduced a ton of boilerplate-y code with those Have fun
@krtirtho
@krtirtho 2 жыл бұрын
react-query
@renegadeace1735
@renegadeace1735 2 жыл бұрын
What's so bad about prop drilling? Verbose yes, but clear and easy to understand, also yes!
@sleepysud
@sleepysud 2 жыл бұрын
Makes it painful to maintain / re-write code.
@Ace_Qnemes
@Ace_Qnemes 11 ай бұрын
Go make something bigger than todo list and you`ll find out
@snakezize
@snakezize 3 жыл бұрын
React-query.
@snakezize
@snakezize 3 жыл бұрын
Redux adds a lot of unnecessary complexity and setup. Even in large projects, most of the time you don't need redux. Also, many times a lot of state don't need to be at the global scope and with redux people tend to put everything as global state. Unless redux middlewares like sagas are needed and are properly used, redux is unnecessary.
@snakezize
@snakezize 3 жыл бұрын
@@shahzadaalihassan_vlogs Yes
@CodingNuggets
@CodingNuggets 3 жыл бұрын
@Jack Saat This is true, but Redux is overkill for many projects.
@unmy400
@unmy400 3 жыл бұрын
I'll write this while i'm still watching the video, so i'll comeback later if the answer is in the video How SWR data that was fetched from an API is available to all my components as a global state? or it is that it doesn't make a fetch to an specific route if it was called previously by another component 🤔
@leerob
@leerob 3 жыл бұрын
SWR provides the caching layer for you. So if you make a request to /api/user, you can use the useSWR() hook in 100 places across your codebase calling that same endpoint, and they're all looking to the same place in the cache!
@abumubarak_dev
@abumubarak_dev 3 жыл бұрын
@@leerob Amazing even without internet connection?
@TeamEternalEmpire
@TeamEternalEmpire 2 жыл бұрын
@@abumubarak_dev yes
@satyamayush2448
@satyamayush2448 9 ай бұрын
Zustand
@jdratlif
@jdratlif 2 жыл бұрын
I think only components that have useContext and their children rerender, not every component under the context provider.
@rpgzan2028
@rpgzan2028 3 жыл бұрын
React Context for context and xstate for state! context is the values you need through a component, state is a state!
@ThomazMartinez
@ThomazMartinez 3 жыл бұрын
Zuuuuuuuustanddddddddd
@suhanbangera884
@suhanbangera884 Жыл бұрын
I was frustrated by redux🥴. I ended up creating my own state management library 🥴🥴
@alejomakevids
@alejomakevids 2 жыл бұрын
I was trying to learn how to luse redux with redux tk, but then the docs mentioned the use of IMMER. It was a totally turn off for me.
@varandpezeshkian6299
@varandpezeshkian6299 3 жыл бұрын
the answer is, all of them, I usually combine context/swr/hooks. Going forward I can see redux become less popular.
@ehsankhorasani_
@ehsankhorasani_ 3 жыл бұрын
I prefer zustand
@matheusvictor9629
@matheusvictor9629 2 жыл бұрын
just don't use redux and you will probably be okay (or better than with redux)
@xseman
@xseman 3 жыл бұрын
none.. more bloat more complexity
@xseman
@xseman 3 жыл бұрын
@Jack Saat Throwing other problems at a problem is not the solution
@mazenfayez5824
@mazenfayez5824 Жыл бұрын
hello, did you try zustland? would like to here your thoughts, i think it is the simplist one so far.
@vasileturus
@vasileturus 3 жыл бұрын
You should use redux, sorry guys
@lardosian
@lardosian 3 жыл бұрын
I think the central store is a big advantage, I have been trying context and use useReducer which is fine for small projects but doesnt feel right as things start to grow.
@vasileturus
@vasileturus 3 жыл бұрын
@@lardosian same here
@ufufu001
@ufufu001 3 жыл бұрын
but it's so hard
@vasileturus
@vasileturus 3 жыл бұрын
@@ufufu001 I agree
@exactzero
@exactzero 3 жыл бұрын
@@ufufu001 Check out redux-toolkit. Much easier and cleaner code.
Picking From 20 React State Managers
35:18
Jack Herrington
Рет қаралды 83 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 149 М.
it takes two to tango 💃🏻🕺🏻
00:18
Zach King
Рет қаралды 32 МЛН
The Worlds Most Powerfull Batteries !
00:48
Woody & Kleiny
Рет қаралды 23 МЛН
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,2 МЛН
My Favorite State Manager Is...URLs?
6:29
Theo - t3․gg
Рет қаралды 68 М.
Why use Recoil in React? | Atoms and Selectors
13:09
CBT Nuggets
Рет қаралды 3,1 М.
React Query Is (Still) Essential - My Favorite React Library
11:04
Theo - t3․gg
Рет қаралды 140 М.
Mastering React Context: Do you NEED a state manager?
37:26
Jack Herrington
Рет қаралды 96 М.
What is my favorite React state management library
29:17
Web Dev Cody
Рет қаралды 11 М.
How to decide between useState, useReducer and XState
8:06
Why I Moved from React Redux to Zustand and Why You Should Too!
19:24
I Tried 5 Redux Alternatives and Here is the Best one
16:48
CoderOne
Рет қаралды 20 М.
This Library Makes State Management So Much Easier
12:07
Web Dev Simplified
Рет қаралды 129 М.
Smarter and Simpler React State
26:46
Jack Herrington
Рет қаралды 55 М.
#miniphone
0:18
Miniphone
Рет қаралды 11 МЛН
ПК с Авито за 3000р
0:58
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,7 МЛН
Не обзор DJI Osmo Pocket 3 Creator Combo
1:00
superfirsthero
Рет қаралды 1,3 МЛН
Mi primera placa con dios
0:12
Eyal mewing
Рет қаралды 491 М.