React Hooks: Advanced Hooks

Поделиться
HTML-код
  • Опубликовано: 5 янв 2025

Комментарии • 237

  • @akalrove4834
    @akalrove4834 3 года назад

    Your teaching style seems calming to me. I have watched a lot of React hooks video but this is the only one that clicked. You deserve a lot more subs and views.

  • @pranav854
    @pranav854 3 года назад

    This is incredible! It's insane that your 20 minute quick tutorial explained context and reducer well than a 250$ react hooks workshop I recently attended.

  • @arpanbanerjee8584
    @arpanbanerjee8584 4 года назад

    You explain the concepts step by step, slowly building on the top of it when u explain some bigger concepts, that helps a lot. We get the idea , why are we using it! Thanks for the video!

  • @Pareshbpatel
    @Pareshbpatel 3 года назад

    Fluently delivered demonstration of how to use the main React Hooks. Thanks, Harry

  • @simonkalu
    @simonkalu 5 лет назад

    A solid example of useReducer, useContext, and useEffect. Welldone, sir

  • @eriboss11
    @eriboss11 4 года назад

    Where have you been , the last few months of my life... Love your videos.

  • @tak68tak
    @tak68tak 5 лет назад

    This is the best tutorial video
    on Hooks on the planet!

    • @hswolff
      @hswolff  5 лет назад

      Wow! Amazing! Thank you!

  • @typescripttips6179
    @typescripttips6179 6 лет назад +13

    Thanks for the video, sir! Hopefully, this prevents some people from preemptively jumping to Redux :)

  • @fiilix99
    @fiilix99 3 года назад

    that is a very solid example of good information of react hooks. nice!
    thank you! subscribed.

  • @workflowinmind
    @workflowinmind 6 лет назад +5

    By far the most comprehensive video on the subject !! Thanks a ton. Subscribed.

  • @ProfJigsaw
    @ProfJigsaw 5 лет назад +4

    The best video I've seen on react hooks. Big ups Harry

    • @hswolff
      @hswolff  5 лет назад

      Thank you sir!!

  • @viraj_singh
    @viraj_singh 4 года назад +20

    I used react in a previous project. Currently I'm working on a project built with Angular. Looking how things have changed with hooks, Angular feels like an old grandma who tells you there's only one way to do it and that's her way.

    • @IconicProps
      @IconicProps 2 года назад

      I feel exactly opposite. React with the inability to really create a singleton for shared state, feels like spaghetti no matter how clean you write it. Don't get me wrong, you can make bad code in any framework, but react seems to force you early on to make the most spaghetti code possible until you gain a mastery of it.

  • @gazzzou
    @gazzzou 5 лет назад

    I am glad I found your channel. You are one of a kind that explain so clearly and deeply in a somewhat funny way. Well done. Keep going please. I already shared with other web fellows!

    • @hswolff
      @hswolff  5 лет назад

      Yay! Thank you for spreading the word!

  • @electroheadfx
    @electroheadfx 3 года назад

    Fast and efficient explanation for hooks in react ! great thanks a lot bro !

  • @rajandavis9294
    @rajandavis9294 3 года назад

    Thank you, got stuck on hooks and this is the perfect video covering the exact usecase I was looking for

  • @jessecrockett
    @jessecrockett 5 лет назад

    i've watched this video three or four times, it's really good. you're now one of only two youtube notify i've allowed :)

    • @hswolff
      @hswolff  5 лет назад

      Oh wow! Thank you! Let me know what else you're interested in learning about!

  • @rluijk
    @rluijk 5 лет назад +1

    Well explained! Nice to see how composing with hooks makes it so easy to make it all look very clean

    • @hswolff
      @hswolff  5 лет назад

      Thank you! Glad it helped!

  • @abhijiths148
    @abhijiths148 3 года назад

    Sooo Smooth in 20 mins... Nice Keep posting

  • @gaboexodia
    @gaboexodia 5 лет назад +1

    The Hooks + Context are clear to me, thanks to you.

    • @hswolff
      @hswolff  5 лет назад

      Glad this helped explain it!

  • @Karlponken
    @Karlponken 4 года назад

    Thanks for this! It's nice seeing them all working together, makes it easier to understand!

  • @wasuuu
    @wasuuu 4 года назад +1

    Holy smokes. First time I've seen your video and I'm delighted :D

  • @chethelesser
    @chethelesser 5 лет назад +3

    The best I've seen on Hooks, great job! Thank you

    • @hswolff
      @hswolff  5 лет назад

      Thank you! Glad it helped!

  • @JAdamMoore
    @JAdamMoore 6 лет назад +10

    "Needling the thread" was all I needed to hear to subscribe.

  • @mstalcup
    @mstalcup 6 лет назад +9

    I am very glad I found you. Subscribed.

  • @mediablitzeast
    @mediablitzeast 5 лет назад

    Thanks for this. I coded along with this video. Learned a lot about hooks, especially the ones that I found to be confusing.

    • @hswolff
      @hswolff  5 лет назад

      Excellent! So glad to hear!

  • @richie-bonilla
    @richie-bonilla 6 лет назад +1

    Thank you! This was a great way to walk through the various hooks and explain how they all fit together. My reptile enjoyed it as well.

  • @PierreOupa
    @PierreOupa 4 года назад

    Excellent video Harry, thanks for sharing your knowledge with us!

    • @hswolff
      @hswolff  4 года назад

      Glad you enjoyed it

  • @mr.somebody6368
    @mr.somebody6368 4 года назад +1

    Hi there, I was wondering what's the difference between just using an boolean instead of useRef then?

  • @adriaanglibert3854
    @adriaanglibert3854 6 лет назад +11

    Great course! Explained very easily 👍

  • @djwave28
    @djwave28 4 года назад

    Just learning React/Redux this was a bit overwhelming, but a lot is recognized. Fun to see another approach on how to go about React. looks flexible, but that also makes it little harder to understand. I will be back to study this one some more ;-)

  • @sukiewang1040
    @sukiewang1040 4 года назад

    You are just amazing! Learnt so many awesome stuff about hooks from you! Just wanna say thank you!

  • @theremotecoder
    @theremotecoder 3 года назад

    Great content! That answers way more questions than I had and came for :)

  • @shawnlee5956
    @shawnlee5956 4 года назад

    clear + simple + direct.
    thanks~ for no advertisement video ^^

  • @gbrivate
    @gbrivate 5 лет назад

    I just refactored an entire app with hooks and Axios observables + Redux Observables also, I was willing to use useReducer instead of Redux, but u know, one thing at the time, as a big fan of RxJS - Observables, I could not get away with Redux Observables ( EPICS ) , anyway I'm very happy with the results of refactoring, now its 100% HOOks :)

    • @hswolff
      @hswolff  5 лет назад

      Heck yeah! So great to hear!

  • @josephwong2832
    @josephwong2832 3 года назад

    nice walkthrough bro. I subbed to your channel!

  • @yoemasey
    @yoemasey 5 лет назад

    Love from India 🇮🇳. Thank you so much for your tutorial.

    • @hswolff
      @hswolff  5 лет назад

      Woo! Thanks for watching! Glad you liked!

  • @tambolaking5383
    @tambolaking5383 4 года назад

    Beautiful. The last bit got way too confusing for me. Useref and custom hook with callback. Purpose of making useEffectsOnce?

  • @mikkomiranda8526
    @mikkomiranda8526 5 лет назад

    I love this no more boilerplate from redux and very easy to use! Thank you for the awesome vid

    • @hswolff
      @hswolff  5 лет назад

      Wooo! Glad you enjoyed!

  • @TrilochanSatapathy
    @TrilochanSatapathy 5 лет назад +1

    Nice Explanation. Learned a lot from it.

  • @jpangelle
    @jpangelle 6 лет назад +1

    Great videos on Hooks man. They were really helpful. Thanks!

  • @Shavyg2
    @Shavyg2 6 лет назад +46

    i comment rarely, solid.

    • @hswolff
      @hswolff  6 лет назад +2

      Thank you! The comment is super appreciated!

    • @jamesstelvin
      @jamesstelvin 4 года назад

      Solid

    • @entertainment11378
      @entertainment11378 4 года назад

      Getting issue automatically call useEffect more than once

  • @MarkDyck
    @MarkDyck 4 года назад

    Thanks for the useRef example. That’s one that I never really ‘got’ before. :)

    • @hswolff
      @hswolff  4 года назад

      Yeah, useRef is tricky.

  • @phqsphqs
    @phqsphqs 3 года назад

    Really nice video! The description of the todo doesn't actually get saved in the localstorage, right? It should be implemented in the onchange of the input, am I wrong?

  • @topogigio10
    @topogigio10 4 года назад

    Great video! Thanks from Argentina
    Pd: I love 12:47 moment

  • @ToniLiem
    @ToniLiem 4 года назад

    Great video dude... really help. Keep up all yr good work

  • @brothercaleb
    @brothercaleb 4 года назад

    Sumptuous architecture. Subbed

  • @StevenHoodlebrink
    @StevenHoodlebrink 4 года назад

    Thanks for the great content. Also, you type insanely fast and I thought I was a fast typer LOL!

    • @hswolff
      @hswolff  4 года назад

      Hahah, I should share that story about why I type fast. It's a funny one.

    • @StevenHoodlebrink
      @StevenHoodlebrink 4 года назад

      @@hswolff Yesss! Story time!

  • @axez2069
    @axez2069 5 лет назад +3

    great demo, would have been nice if the text would stick after reload.

    • @chethelesser
      @chethelesser 5 лет назад +1

      Add to reducer:
      case "change":
      return state.map(item =>
      item.id === payload.id ? { ...item, text: payload.value } : item
      );
      Add to input:
      onChange={({ target: { value } }) =>
      dispatch({ type: "change", payload: { id, value } })
      }
      Voila

    • @danielhughes3758
      @danielhughes3758 4 года назад

      Thank you so much! I also noticed that the text didn't stick around and your answer shows how I can send any value I want to a dispatch method and thereby change the state of the context from anywhere.

  • @julianjacobs8956
    @julianjacobs8956 5 лет назад

    fantastic video! great pace with good content. subscribed

    • @hswolff
      @hswolff  5 лет назад

      Hey, thanks! Welcome aboard!

  • @ΓιάννοςΧ
    @ΓιάννοςΧ 5 лет назад

    Very nice tutorial amigo. I'm hooked. Humor made me subscribe and I am glad I stumbled upon you :)

    • @hswolff
      @hswolff  5 лет назад

      Thank you! I’m glad you stumbled here too! Get other people to stumble in! :)

  • @nithincs
    @nithincs 4 года назад

    Cool video, thanks for that, one question about using hooks outside of the components, is that a correct way of doing, because I hear it cause unpredictable behaviour ? 18:00 ( useRef used in a independent function )

  • @alexmalinin2387
    @alexmalinin2387 5 лет назад +3

    Hmm, does your useEffectOnce hook make sence, since we can pass an empty array to useEffect's dependencies (2nd argument)? Because your effect still runs on every render tho
    But interesting usage of ref, wondered to see what is stated in react docs for this usage case

    • @mragrayson
      @mragrayson 5 лет назад

      He did explain it was for educational purposes that he was doing that.

  • @kambaalayashwanth123
    @kambaalayashwanth123 6 лет назад +1

    Can you make same logic to work by making individual component files,

  • @raghavjha8996
    @raghavjha8996 5 лет назад

    Thanks for such a nice video lecture. Love from India!

    • @hswolff
      @hswolff  5 лет назад

      You are welcome! Hello India!

  • @RegisZaleman
    @RegisZaleman 3 года назад

    Nice and clear, you got my sub with this one :)

  • @dimor22
    @dimor22 5 лет назад

    Thank you, it was very clear to the point video tutorial. Definitely learned something new

    • @hswolff
      @hswolff  5 лет назад

      Wonderful! So glad to hear!

  • @pjguitar15
    @pjguitar15 3 года назад

    Is Reducer the same with Redux?

  • @voalcalisticTanmay
    @voalcalisticTanmay 5 лет назад

    Well a nice video to understand advanced hooks provided with react.
    But one question ... just for curiosity. ... using useRef in the example is more efficient than useEffect with blank array to get it executed once or vice-versa?

    • @hswolff
      @hswolff  5 лет назад

      Which example is that? Not sure which you're referring to.

  • @soujvnunes
    @soujvnunes 4 года назад

    15:15 couldn’t you use useLayoutEffect?

  • @pbdivyesh
    @pbdivyesh 5 лет назад

    After creating useEffectOnce() my todoList kept flickering, why so? Is it because it is still kept re-rendering since each time the data was empty, I mean it was the 'completed` was as it is and the input fields weren't changed
    *_EDIT_* : figured it out I forgot put the conditiional (if) to check if the didRun.current is false

    • @hswolff
      @hswolff  5 лет назад

      Woohoo! Glad you figured it out!

  • @kivylius
    @kivylius 5 лет назад

    love it, great tutorial! i would like to see more examples of advanced hooks.

    • @hswolff
      @hswolff  5 лет назад

      Glad you liked it!

  • @aniketpaul5118
    @aniketpaul5118 5 лет назад

    Great explanation. Keep up the good work. Subscribed.

    • @hswolff
      @hswolff  5 лет назад

      Hey, thanks for the sub!

  • @elyesstekaya4565
    @elyesstekaya4565 5 лет назад

    In ths react docs, it's not allowed to use conditions (if statements...) or loops (for statements..) in a hook, in this tuto you use it with "useRef" hook (if (!didRun.current){... ) I m confusing if its only allowed with "useRef" hook ??

    • @hswolff
      @hswolff  5 лет назад +1

      Great question. You can not conditionally use a hook. I.e. doing if (true) { useRef() } is not allowed. You can however use the results of a hook in conditionals.
      Does that help?

  • @RockeTommi
    @RockeTommi 5 лет назад

    question, How do you pass Context to another component(different file), to be able to use dispatch() in that component?

    • @danieldawson8018
      @danieldawson8018 5 лет назад

      You can use useContext just like he does in the video at the 10 minute mark. That will be available to any component in the tree wrapped by the provider. Since in this case he's wrapping the whole app in the provider, you could use useContext anywhere in the apps component tree.

  • @tir3dnow792
    @tir3dnow792 4 года назад

    I would so so much appreciate it if you could please do this exact tutorial, but with TypeScript.
    I would love a link to a typescript version of this project, if there is one.

    • @tir3dnow792
      @tir3dnow792 4 года назад

      PS: Finished writing a TypeScript version of it.

  • @alkismavridis1
    @alkismavridis1 5 лет назад

    React becomes better and better.
    Nice video! 👍

  • @NotYourAverageCitizens
    @NotYourAverageCitizens 5 лет назад

    great video! have a much better understanding of hooks after this

  • @Ihabkhattab
    @Ihabkhattab 6 лет назад +1

    Thanks Harry! this is really cool one 👏

  • @GeraldScholz
    @GeraldScholz 5 лет назад

    What about performance and useeffect combined with useRef. You created a infinite loop ?

    • @hswolff
      @hswolff  5 лет назад +1

      I did? Where?! :o

    • @GeraldScholz
      @GeraldScholz 5 лет назад

      Line 45, I thought useeffect is running constantly without the second argument. So your if statement didrun.current gets called all the time. Or am I mistaken?

  • @tylereikenberg9651
    @tylereikenberg9651 4 года назад

    Great video! Anything you would do differently with this now in 2020?

  • @stoneZ-DLR-au
    @stoneZ-DLR-au 4 года назад

    thanks for your demo. very helpful

  • @paramjeetdhiman1997
    @paramjeetdhiman1997 2 года назад

    Thank you sir, Well explained!

  • @danielattiach9224
    @danielattiach9224 6 лет назад

    Thank you sir, greatly appreciated!
    Wonder if you could shortly explain how you'd approach this "issue":
    I did that when you press enter in the text input, the todo has pure text instead of the input.
    How would you tackle that? I called a dispatch with a type of 'submit' that sets the text in the state.
    Then in my TodoItem function I check if text === "" and return 2 different components for each case because of that.
    Looking for a more elegant solution. Thanks!

    • @hswolff
      @hswolff  6 лет назад

      I think checking if text === "" is a fine solution to decide what component to render. The source of truth here is "did the user enter in text" and using the value of the text directly to make that decision is the best way to do it!

    • @danielattiach9224
      @danielattiach9224 6 лет назад

      @@hswolff Alright, thanks a lot!

  • @axe-z8316
    @axe-z8316 5 лет назад +1

    wish you would explain a bit more the new features, tried to do the app after, got stuck, with useEffect, not really knowing when they get triggered, or what that last [state] array represents. The flow of it all needs explaining, for me at least. Pretty sure i'm not the only one. Otherwise, great tempo, delivery, great job.

    • @philtrem
      @philtrem 5 лет назад

      Watch the original talk introducing hooks. UseEffect is very well explained there , I think. Dan Abramov explains its main points, and then Ryan Florence goes more in-depth.

    • @axez2069
      @axez2069 5 лет назад

      @@philtremmerci !!

  • @JohnCely
    @JohnCely 3 года назад

    Nice explanation!

  • @carlosricardoziegler2650
    @carlosricardoziegler2650 3 года назад

    Really Nice! Thank you man!

  • @MrPlaiedes
    @MrPlaiedes 6 лет назад +1

    Nicely done sir!

  • @vaibhavm1986
    @vaibhavm1986 6 лет назад

    Hey Harry, recently started to follow ur vidoes, and like the way u explain concepts... Please make vidoes using typescript

    • @hswolff
      @hswolff  6 лет назад +1

      Thanks for the follow! TypeScript videos is definitely in the queue! Such an exciting topic!

    • @vaibhavm1986
      @vaibhavm1986 6 лет назад

      @@hswolff Yeah because in my opinion enterprise applications have lot of code and typescript is beneficial for large code base...after watching ur channel my expectations have increased
      I expect much more now from your future vidoes especially from real worl examples....keep it up creative work! 😊

  • @richravestein9712
    @richravestein9712 6 лет назад +1

    I learned a lot! Thanks Harry!

  • @jamestacular
    @jamestacular 3 года назад

    I feel like you kinda skipped explaining why you put an empty array as your second param for your useEffect. This second paramater expects an array of dependencies. If any item in this array is changed, this useEffect will fire the callback function you passed to it. By using an empty array by default it will only run the callback once when the component mounts.

  • @har.ie_
    @har.ie_ 5 лет назад

    Probably a stupid question, but why do you have to stringify your data when saving it to local storage, and then parse it again on the reset?

    • @hswolff
      @hswolff  5 лет назад

      Not a stupid question at all! localStorage only accepts strings as keys and values. From developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
      The keys and the values are always strings (note that, as with objects, integer keys will be automatically converted to strings).
      So JSON.stringify converts an object to a string so we can store it in storage!

    • @har.ie_
      @har.ie_ 5 лет назад

      @@hswolff Wow nice, you learn something new every day. Thanks for the reply!

  • @eleah2665
    @eleah2665 6 лет назад

    If useEffectOnce ran a second time, why would line 41 (initial setting of didRun) NOT set didRun.current back to false?

    • @eleah2665
      @eleah2665 6 лет назад +1

      I figured this out. useEffectOnce only runs once because it is called only once.. The useEffect inside it may run many times, but didRun.current is still available to it through javascript closures. Wow! That really stretched my js knowledge. I need to take a nap now. Thanks new dad and recently moved Harry.

  • @eminem2
    @eminem2 6 лет назад +1

    Many many thanks for your useful content!

  • @nove1398
    @nove1398 5 лет назад

    Great video, I actually learned a lot being new to react and all. However I know you have video time concerns which is why you must have been going so fast, but I found myself putting back the video a whole lot to catch up on each point. If you went a bit slower and even so made the video a bit longer would be awesome. Cheers

    • @hswolff
      @hswolff  5 лет назад +1

      Good feedback! Will keep it in mind going forward!

    • @nove1398
      @nove1398 5 лет назад

      @@hswolff looking forward for more content and spreading the word

  • @ashantharindu8915
    @ashantharindu8915 3 года назад

    Well explained. Thank you

  • @SimPwear84
    @SimPwear84 4 года назад

    Outstanding Content, subbed!!

  • @mahendranath2504
    @mahendranath2504 4 года назад +1

    I like your thank you so much. a happy subscriber, amazing content .. can you do a series on react typescript

  • @AbhishekKumar-mq1tt
    @AbhishekKumar-mq1tt 5 лет назад +3

    Thank u for this awesome video

  • @josenunez5983
    @josenunez5983 4 года назад

    Thanks! I enjoyed and learned a lot

  • @MarstanMobilOyunlar
    @MarstanMobilOyunlar 3 года назад

    This is an amazing video.

  • @nDenTzMotionZztrujillo
    @nDenTzMotionZztrujillo 6 лет назад

    Does this replace redux? Or at least is moving towards that direction?

    • @hswolff
      @hswolff  6 лет назад +1

      It doesn't completely replace Redux. You are correct, it is moving in that direction.

  • @footstepparecords
    @footstepparecords 4 года назад

    This is so dope! Thanks.

  • @ugopalatucci
    @ugopalatucci 5 лет назад

    Great video. Thanks . I have learned a lot.

    • @hswolff
      @hswolff  5 лет назад

      Woo! So glad to hear! Thank you!

  • @ricardovoegeli5359
    @ricardovoegeli5359 5 лет назад

    Greats videos! Do you have some example how to use callback and usememo?

    • @hswolff
      @hswolff  5 лет назад +1

      Great suggestion! That'd be nice to show! I'll add it to my queue of videos!

  • @rohan4035
    @rohan4035 4 года назад

    This is what I need!!!

  • @DanelonNicolas
    @DanelonNicolas 6 лет назад +1

    we learn a lot! thanks!

    • @hswolff
      @hswolff  6 лет назад +1

      Woohoo! Glad to hear!

  • @tslqs
    @tslqs 4 года назад

    Thanks, this is awesome

  • @blackyurizan
    @blackyurizan 4 года назад

    this was awesome

  • @justfly1984
    @justfly1984 6 лет назад +1

    Great video!

  • @FernandoPonteFilho
    @FernandoPonteFilho 6 лет назад

    Great video, I'm still struggling with app organization, as a beginner, learning how to "react" to states using redux and they change so many things it's not impossible, but hard to keep up with.
    Sorry to say, but this empty array/useRef are not that clear why at first, we have to be used with the api and docs, but thanks for your explanation.

    • @hswolff
      @hswolff  6 лет назад

      Anything in specific you're confused about?

    • @FernandoPonteFilho
      @FernandoPonteFilho 6 лет назад

      ​@@hswolff I think not so specific. May need get used with the new Api. Was looking for comments from other people and could see a few thinks same as I do, that this useEffect gonna be hard to predict for beginners.
      Another hard change could be app folder organization. I'm new to this, you may not know how hard is to wakeup everyday with a "Use this way, not this way" as I'm still learning, sometimes preferring a really more opinionated way to do, because I don't see (yet) how could use like we do now with redux and async calls (like thunk and saga).
      But loved how we're directing for less class for those who won't use and more functional JS.
      Maybe a video could be: "Doing with Hook as we did with Redux before" or... "See? It doesn't bite."
      Sorry to take your time, I'm pleased to meet the channel.

    • @hswolff
      @hswolff  6 лет назад +1

      Thank you for the reply!
      I think Redux still does things that Hook doesn't do. There is overlap however I haven't fully discovered what that overlap is. If I do I'll happily make a video, but while I'm still learning I'll say nothing :)

    • @FernandoPonteFilho
      @FernandoPonteFilho 6 лет назад

      ​@@hswolff No, I thank you. Hope we finally get this more clearly.

    • @ddubs123
      @ddubs123 6 лет назад +2

      @@FernandoPonteFilho I wouldn't spend much time worrying about folder organization. I did this when I first started out, and never came to any solid conclusion. Organization can change depending on the type of project. Just start with a flat structure of all of your files in one directory. As the project grows you may start to notice related files. When you've identified these related files, put them into a single directory.
      As you become more experienced you will come to your own conclusions on how to organize your app. The nice thing about React is it's much easier to move things around and refactor than a typical framework.