Learn React Hooks: useReducer - Simply Explained!

  Рет қаралды 71,460

Cosden Solutions

Cosden Solutions

Күн бұрын

Пікірлер: 91
@cosdensolutions
@cosdensolutions 4 ай бұрын
Hope you enjoyed the video! I also have a really cool and unique course that will teach you way more than this video. You'll learn how to build an actual complex project with React. It's called "Project React" and you can find it at cosden.solutions/project-react. Also, I have a free weekly newsletter called "Import React" with tutorials, news, and cool stuff about React! You can sign up at cosden.solutions/newsletter?s=ytc
@forshetrial
@forshetrial 9 ай бұрын
honestly, you're underrated. i learned more things from you than my college course.
@es7729
@es7729 8 ай бұрын
Agreed. Definitely channel to recommend.
@catarinasilva7390
@catarinasilva7390 Жыл бұрын
Dude, you are soooo underrated. 600 views? this video deserves a million views. can't even tell you how many different videos i watched about useReducer and finally you found a way to explain it perfectly. Finally got it 🙏🙏 thank you thank you thank you..
@cosdensolutions
@cosdensolutions Жыл бұрын
I'm really glad to hear that! ☺️ thanks a lot
@JasonRosensweig
@JasonRosensweig Жыл бұрын
I just want to say that these react hooks videos are by far the best and easiest to understand. They are fantastic for new devs and senior devs just getting into react. 😊
@es7729
@es7729 8 ай бұрын
1:28 to 1:48, just summarization and I already got what it does. I did not use it really, but used redux, so it absolutely made sense. Thanks!
@tanmayawasthi6487
@tanmayawasthi6487 10 ай бұрын
Thank you so much Cosden! I've seen so many videos but it's just amazing how you are making this so simple.
@WaffleStompz
@WaffleStompz Жыл бұрын
This series on React hooks has been super informative. Really appreciate this content, these may be the best explanation videos I have ever watched, for any language.
@cosdensolutions
@cosdensolutions Жыл бұрын
Damn, thanks! Means a lot 🤙
@Antebios
@Antebios 12 күн бұрын
I've been binging your videos because you make it so easy to understand!! ❤️
@AnilYalcinkaya-m2o
@AnilYalcinkaya-m2o Жыл бұрын
There is no other way to explain it easier than you did in this video... just mindblown :) Thanks for the video Cosden! 👏
@cosdensolutions
@cosdensolutions Жыл бұрын
glad to hear it!
@christopherlopez2491
@christopherlopez2491 8 ай бұрын
I feel like I just made it over a slump/ hurdle I’ve been stuck in for too long. But seriously… you’re videos have been SO helpful is getting over these hang ups. I appreciate what you’re doing here.
@evgenystarinsky8582
@evgenystarinsky8582 Жыл бұрын
Please keep up doing videos like that! Very concise and clear!
@cosdensolutions
@cosdensolutions Жыл бұрын
Will do!
@adussa3
@adussa3 8 ай бұрын
Thank you for explaining things so clearly! I finally understand the useReducer now! I do have one question. Around 12:19 you mentioned that "[useReducer] can update multiple pieces of state at once. If we had done this with useState, you probably would have had a state value for count and then a state value for error" I'm a little confused about what you meant by this. Are you saying that you would need two separate states for count and error? Couldn't we have a state that holds an object with both count and error values and do the same thing in the useReducer example, like this: const [state, setState] = useState({ count: 0, error: null }); const increment = () => { setState((prevState) => { const newCount = prevState.count + 1; const hasError = newCount > 5; return { ...prevState, count: hasError ? prevState.count : newCount, error: hasError ? "Maximum reached" : null }; }); }; const decrement = () => { setState((prevState) => { const newCount = prevState.count - 1; const hasError = newCount < 0; return { ...prevState, count: hasError ? prevState.count : newCount, error: hasError ? “Minimum reached" : null }; }); };
@marceloviannadev
@marceloviannadev 3 ай бұрын
You can call dispatch wherever you need to update multiple states at the same time for EX: if you have 3 actions and wanna call them inside a try-catch: try { const response = await ... dispatch({ type: "SET_ACTION_1" }); dispatch({ type: "SET_ACTION_2", payload: ... }); dispatch({ type: "SET_ACTION_3", products: ... }); } catch (error) { dispatch({ type: "SET_ACTION_1_ERROR", message: "Error on action 1" }); console.log ... } };
@culturehyena
@culturehyena 19 сағат бұрын
I think he just means that the intuitive way to use state is to have one state per value. You can indeed build something similar to the reducer pattern using state, but the way useReducer does things is well-established and predictable, so other engineers will know immediately how to work with your code. Reducers are easier to test and debug because they’re at a remove from the component, and it’s less fiddly to pass a single dispatch function around your component tree than it is a selection of setState wrappers.
@ignatiuschandrachristian1774
@ignatiuschandrachristian1774 3 ай бұрын
Yep, I really don't need to see another tutorial on useReducer, yours is enough!
@brunobrasil3419
@brunobrasil3419 7 ай бұрын
Thank you so much! Your channel will grow lots with your great, clear, and concise explanations!
@robboerman9378
@robboerman9378 7 ай бұрын
Super clear and explanation again, the last example drove home the point on when to use it
@CalebHall-ye5in
@CalebHall-ye5in 2 ай бұрын
THE GOAT - Greatest Of All Teachers 🔥🐐
@gpavankumar175
@gpavankumar175 2 ай бұрын
Awesome video about the advanced useReducer hook.. Thanks for making understanding us. I expect more examples just to tell in video where this could be example so that decision to use becomes little more simple
@magiclover9346
@magiclover9346 9 ай бұрын
It's important to understand the strictness of immutability is enforced. If you don't return a new object in your reducer the component will not re-render. This is a bit different if you're coming from redux-toolkit. Redux toolkit will give you a brand new object in your reducers. Great video
@SelfMotivation863
@SelfMotivation863 Жыл бұрын
even my english is very bad but i can understand evry word you saying , and that's help me to get the information , thanks bro❤
@mahmoudwalid1703
@mahmoudwalid1703 8 ай бұрын
Your content is really very useful. Easy and simple. It makes it easy for me 🥰🥰🥰 The way you explain is very similar to Jonas Schmedtmann😅🥰
@nanonkay5669
@nanonkay5669 9 ай бұрын
I think if you find yourself having to update 4+ instances of state that all depend on each other in some capacity, its time to use useReducer
@Onto.walking
@Onto.walking 3 ай бұрын
By far underrated
@thebeastsclips
@thebeastsclips Жыл бұрын
The 12:18 explains it.❤
@devdesiignn
@devdesiignn 7 ай бұрын
Darius, This is great, Thank you so much for these contents you put out, i just joined the discord and i am excited about what you have on there, it is really mind blowing... I want to suggest if you can make a YT short video, to talk about sample scenarios when it's is suitable to use useReducer instead of useState. I feel this might clarify things better for Jr react devs like me. Thank you.
@harag9
@harag9 Жыл бұрын
Great video. I've watched several vids trying to explain useReducer, and each time a little more sinks in, I just have to go and use it. It looks so simple when it's all on one page within one component. but when I have several pages and several components, and then need to throw it into a useContext or something for it to be accessible to them all
@cosdensolutions
@cosdensolutions Жыл бұрын
Yep exactly, that's actually what redux is! So you may want to consider it if your state is big enough
@maxkalashnyk3378
@maxkalashnyk3378 8 ай бұрын
The best explanation I've ever heard. I wish the best from Ukraine
@abdulkhaleque9363
@abdulkhaleque9363 10 ай бұрын
I'm really greatefull to you for making video like these.......
@jenlesamuel
@jenlesamuel 4 ай бұрын
Great video as always
@leonardmbibi8013
@leonardmbibi8013 Жыл бұрын
I first of all like your video before watching - that tells you the confidence I have in you. I'll follow you on social media if you make your handles available and more...
@cosdensolutions
@cosdensolutions Жыл бұрын
all my handles are the same as this one, @cosdensolutions
@shaiienn
@shaiienn Жыл бұрын
Such a great tutorial! Thank you and just subscribed :)
@johnacsyen
@johnacsyen Жыл бұрын
Very clearly explained. Thanks for making this . Subscribed.
@stevebuonincontri6853
@stevebuonincontri6853 3 ай бұрын
Thanks for the video - was great - which pattern would you use to switch a theme in react?
@iwantfrens5804
@iwantfrens5804 2 ай бұрын
Your explanation is fcking amazing.
@Oksana3dfit
@Oksana3dfit 4 ай бұрын
Thanks a lot! Generaly, I work with zustand state manager. And I see that I can use either useReducer or zustand to reach this result, right? Which one is better to use?
@marceloviannadev
@marceloviannadev 3 ай бұрын
Very depends on the complexity of your project or feature. Simple = useState, medium = useReducer, hard = contextAPI, hardcore = zustand or redux
@touhidsourav2475
@touhidsourav2475 2 ай бұрын
what vscode theme do you use?
@anavashagashvili3308
@anavashagashvili3308 10 ай бұрын
Great video! You helped me a lot. Thank you
@mehdijeyrani7346
@mehdijeyrani7346 5 ай бұрын
perfect master😍😍
@erfelipe
@erfelipe 8 ай бұрын
Great explanation.
@ranjaysingh919
@ranjaysingh919 Жыл бұрын
All things Simply Explained exactly.
@jacobwwarner
@jacobwwarner 7 ай бұрын
I heard a simple rule of thumb saying to useReducer() when updating objects in the state and useState() when updating simple, primitive variables.
@PLAY_Arcade
@PLAY_Arcade 6 ай бұрын
Hi! kind of new here with Reducer. If I'm not wrong, while calling the dispatch function, it basically calls the reducer function, and takes the the "action"(2nd params) as the actual parameter by ignoring the "state"(1st params) by default. Is that correct?
@pumpkinlyla7287
@pumpkinlyla7287 Жыл бұрын
thank you so much for the explanation!
@fatheymohamed140
@fatheymohamed140 Жыл бұрын
hi, great tutorial what is this browser you used in this tutorial
@pame187
@pame187 11 ай бұрын
voy aprendiendo y tambien me voy enamorando jajajajajajajajajajajajajaja muchas gracias🌹 mi crush de react, amor al primer video 😍 jajajjajjaja
@ravikanna1837
@ravikanna1837 Жыл бұрын
Please try to do series on storybook, react testing and typescript
@capt_vj
@capt_vj 10 ай бұрын
Video on RTK query?
@thekadirgun
@thekadirgun 11 ай бұрын
I remember again why I use Vue 😄
@hobbyxplorer
@hobbyxplorer 6 ай бұрын
im currently rewriting this complex ui that was using useState to useReducer. I was using array index to track items and React kept getting confused and not updating the correct item. now 3 days laters it still doesnt work. Glad to see React become the new jQuery. Front end sucks
@sayf3446
@sayf3446 Жыл бұрын
Nice explanation! Really enjoyed that :) May I ask if you can do videos on implementing Typescript + React in Clean Architecture/DDD? These topics and specific tech stack are very few in this space, and would be valuable to junior devs who join bigger teams...tq! Hope to join the discord soon!
@cosdensolutions
@cosdensolutions Жыл бұрын
Glad you liked it! I'm actually building an app live from scratch where I talk about these things, you can check it out! The first video is posted already. I'll eventually make more specific content around that too but for now there's the live where it's an actual project
@NupurPanjiar
@NupurPanjiar 2 ай бұрын
I am unable to purchase the Project React. The message I receive is "Your payment could not be processed". I have written to the support team. There has been no response. Can you please help.
@maso4u
@maso4u Жыл бұрын
Really great video
@Psychopatz
@Psychopatz Жыл бұрын
I'm a visual learner, and him murmuring about the technicalities and jargon instead of showing it then explaining what he did makes this tutorial painful to follow yet its still sufficient, ty
@Imam.Mehdi_
@Imam.Mehdi_ Жыл бұрын
You are right,,,he does not teach he just comment on code
@OjayMatuso
@OjayMatuso 10 ай бұрын
“Learning styles” are a myth.There’s no such a thing as visual learning. Differences in IQ is what determines the difficulty of learning. You’re just slow bro
@anonysmooth648
@anonysmooth648 10 ай бұрын
I watched and I understand, there is no problem on the tutorial
@robboerman9378
@robboerman9378 7 ай бұрын
The whole difference between other explanations is that Darius explains when and why to use it. If all you want to see is people typing useReducer then why watch this tutorial?
@2011BIRR
@2011BIRR 7 ай бұрын
very nice! But as a teacher it is also good to speak a little slower...that would be my wish. I ´ve seen lots of tube videos, where guys think to be clever and don´t think about pupils learning and bombard with talking...
@kassihassan
@kassihassan 6 ай бұрын
you earned my subscribe (Y)
@crutz3064
@crutz3064 Жыл бұрын
useReducers looks like the complicated version of useState..what am i missing? lol
@cosdensolutions
@cosdensolutions Жыл бұрын
It is hahah but it's useful when you have complicated state and want to handle it predictably
@michaeltrembovler8301
@michaeltrembovler8301 Жыл бұрын
Just great !!!
@ask43242flight
@ask43242flight Жыл бұрын
Thank you!
@kiwi..._
@kiwi..._ Жыл бұрын
Bro ,we need beginners react project
@iamparmjeetmishra
@iamparmjeetmishra 7 ай бұрын
thanks
@MohammedShibincp
@MohammedShibincp Жыл бұрын
Really Good
@VishalSharma-rn7mt
@VishalSharma-rn7mt Жыл бұрын
Awesome
@ProGamer-tw3wr
@ProGamer-tw3wr 13 күн бұрын
YOO chico
@mohammadamaan9254
@mohammadamaan9254 Жыл бұрын
it would be better if you did not used typescript
@lll-vq6pm
@lll-vq6pm 5 ай бұрын
They're right its painful to follow. The way you explain things is not begginer friendly. I think you should explain while coding line by line.
@lloydbonds9268
@lloydbonds9268 4 ай бұрын
I think these are some of the best descriptions of react hooks I’ve ever watched.
@bujinkanatori
@bujinkanatori 15 күн бұрын
I dont get it, pretty complex
@ShortContent853
@ShortContent853 Ай бұрын
I'm Jewish
@avatar7166
@avatar7166 Жыл бұрын
i'll never understand this stupid hook 😢
@cosdensolutions
@cosdensolutions Жыл бұрын
yes, you will, you just watched my video! ☺️
@avatar7166
@avatar7166 Жыл бұрын
@@cosdensolutions ive watched tons by many different great channels and still makes no sense to me i understand the use of it but not the structure of it
@voldemortvi4264
@voldemortvi4264 Жыл бұрын
trust me i know how u feel, but dont give up , im not giving up untill i master this shit !
@Pareshbpatel
@Pareshbpatel Жыл бұрын
The useReducer hook, so clearly and succintly explained. Thank you very much. PS One of the few Tutors to illustrate React with TypeScript code. You have to be commended for that. {2023-10-18}
@cosdensolutions
@cosdensolutions Жыл бұрын
Glad it was helpful!
@phenixbd
@phenixbd 3 ай бұрын
Excellent
@somestrangerstories
@somestrangerstories 6 ай бұрын
Thanks
Learn React Hooks: useImperativeHandle - Simply Explained!
9:54
Cosden Solutions
Рет қаралды 25 М.
Learn React Hooks: useCallback - Simply Explained!
17:15
Cosden Solutions
Рет қаралды 110 М.
Learn useReducer In 20 Minutes
20:12
Web Dev Simplified
Рет қаралды 521 М.
Learn React Hooks: useEffect - Simply Explained!
14:07
Cosden Solutions
Рет қаралды 176 М.
Learn React useReducer Hook with Examples
14:19
Lama Dev
Рет қаралды 181 М.
Learn React Hooks: useTransition - Simply Explained!
10:41
Cosden Solutions
Рет қаралды 30 М.
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 117 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 493 М.
The Rust Survival Guide
12:34
Let's Get Rusty
Рет қаралды 170 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 177 М.