React Hooks: Advanced Hooks

Поділитися
Вставка
  • Опубліковано 24 січ 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.

  • @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.

  • @eriboss11
    @eriboss11 4 роки тому

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

  • @simonkalu
    @simonkalu 5 років тому

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

  • @Pareshbpatel
    @Pareshbpatel 3 роки тому

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

  • @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!

  • @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!

  • @tak68tak
    @tak68tak 5 років тому

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

    • @hswolff
      @hswolff  5 років тому

      Wow! Amazing! Thank you!

  • @fiilix99
    @fiilix99 3 роки тому

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

  • @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

  • @ProfJigsaw
    @ProfJigsaw 5 років тому +4

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

    • @hswolff
      @hswolff  5 років тому

      Thank you sir!!

  • @jessecrockett
    @jessecrockett 6 років тому

    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  6 років тому

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

  • @workflowinmind
    @workflowinmind 6 років тому +5

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

  • @typescripttips6179
    @typescripttips6179 6 років тому +13

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

  • @electroheadfx
    @electroheadfx 3 роки тому

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

  • @josephwong2832
    @josephwong2832 3 роки тому

    nice walkthrough bro. I subbed to your channel!

  • @JAdamMoore
    @JAdamMoore 6 років тому +10

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

  • @rajandavis9294
    @rajandavis9294 3 роки тому

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

  • @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!

  • @abhijiths148
    @abhijiths148 3 роки тому

    Sooo Smooth in 20 mins... Nice Keep posting

  • @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!

  • @gaboexodia
    @gaboexodia 5 років тому +1

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

    • @hswolff
      @hswolff  5 років тому

      Glad this helped explain it!

  • @wasuuu
    @wasuuu 4 роки тому +1

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

  • @PierreOupa
    @PierreOupa 4 роки тому

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

    • @hswolff
      @hswolff  4 роки тому

      Glad you enjoyed it

  • @Karlponken
    @Karlponken 4 роки тому

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

  • @shawnlee5956
    @shawnlee5956 4 роки тому

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

  • @chethelesser
    @chethelesser 5 років тому +3

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

    • @hswolff
      @hswolff  5 років тому

      Thank you! Glad it helped!

  • @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!

  • @theremotecoder
    @theremotecoder 3 роки тому

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

  • @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.

    • @hswolff
      @hswolff  6 років тому

      Hahah good :)

  • @mstalcup
    @mstalcup 6 років тому +9

    I am very glad I found you. Subscribed.

  • @mr.somebody6368
    @mr.somebody6368 4 роки тому +1

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

  • @sukiewang1040
    @sukiewang1040 4 роки тому

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

  • @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.

  • @MarkDyck
    @MarkDyck 4 роки тому

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

    • @hswolff
      @hswolff  4 роки тому

      Yeah, useRef is tricky.

  • @brothercaleb
    @brothercaleb 4 роки тому

    Sumptuous architecture. Subbed

  • @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 ;-)

  • @yoemasey
    @yoemasey 5 років тому

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

    • @hswolff
      @hswolff  5 років тому

      Woo! Thanks for watching! Glad you liked!

  • @ΓιάννοςΧ
    @ΓιάννοςΧ 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! :)

  • @ToniLiem
    @ToniLiem 4 роки тому

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

  • @RegisZaleman
    @RegisZaleman 3 роки тому

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

  • @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!

  • @kambaalayashwanth123
    @kambaalayashwanth123 6 років тому +1

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

  • @TrilochanSatapathy
    @TrilochanSatapathy 5 років тому +1

    Nice Explanation. Learned a lot from it.

  • @julianjacobs8956
    @julianjacobs8956 5 років тому

    fantastic video! great pace with good content. subscribed

    • @hswolff
      @hswolff  5 років тому

      Hey, thanks! Welcome aboard!

  • @jpangelle
    @jpangelle 6 років тому +1

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

    • @hswolff
      @hswolff  6 років тому

      Glad to hear!

  • @topogigio10
    @topogigio10 4 роки тому

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

  • @adriaanglibert3854
    @adriaanglibert3854 6 років тому +11

    Great course! Explained very easily 👍

  • @tambolaking5383
    @tambolaking5383 5 років тому

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

  • @stoneZ-DLR-au
    @stoneZ-DLR-au 4 роки тому

    thanks for your demo. very helpful

  • @aniketpaul5118
    @aniketpaul5118 5 років тому

    Great explanation. Keep up the good work. Subscribed.

    • @hswolff
      @hswolff  5 років тому

      Hey, thanks for the sub!

  • @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.

  • @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?

  • @raghavjha8996
    @raghavjha8996 5 років тому

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

    • @hswolff
      @hswolff  5 років тому

      You are welcome! Hello India!

  • @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!

  • @kivylius
    @kivylius 5 років тому

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

    • @hswolff
      @hswolff  5 років тому

      Glad you liked it!

  • @paramjeetdhiman1997
    @paramjeetdhiman1997 2 роки тому

    Thank you sir, Well explained!

  • @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!

  • @JohnCely
    @JohnCely 3 роки тому

    Nice explanation!

  • @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 )

  • @tylereikenberg9651
    @tylereikenberg9651 4 роки тому

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

  • @NotYourAverageCitizens
    @NotYourAverageCitizens 5 років тому

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

  • @soujvnunes
    @soujvnunes 4 роки тому

    15:15 couldn’t you use useLayoutEffect?

  • @ashantharindu8915
    @ashantharindu8915 3 роки тому

    Well explained. Thank you

  • @pjguitar15
    @pjguitar15 3 роки тому

    Is Reducer the same with Redux?

  • @carlosricardoziegler2650
    @carlosricardoziegler2650 4 роки тому

    Really Nice! Thank you man!

  • @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.

  • @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!

  • @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! 😊

  • @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?

  • @richravestein9712
    @richravestein9712 6 років тому +1

    I learned a lot! Thanks Harry!

  • @alkismavridis1
    @alkismavridis1 5 років тому

    React becomes better and better.
    Nice video! 👍

    • @hswolff
      @hswolff  5 років тому +1

      Thank you!

  • @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?

  • @ugopalatucci
    @ugopalatucci 5 років тому

    Great video. Thanks . I have learned a lot.

    • @hswolff
      @hswolff  5 років тому

      Woo! So glad to hear! Thank you!

  • @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 !!

  • @mahendranath2504
    @mahendranath2504 4 роки тому +1

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

  • @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.

  • @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!

  • @josenunez5983
    @josenunez5983 4 роки тому

    Thanks! I enjoyed and learned a lot

  • @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.

  • @MarstanMobilOyunlar
    @MarstanMobilOyunlar 3 роки тому

    This is an amazing video.

  • @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

  • @eminem2
    @eminem2 6 років тому +1

    Many many thanks for your useful content!

  • @Ihabkhattab
    @Ihabkhattab 6 років тому +1

    Thanks Harry! this is really cool one 👏

  • @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.

  • @AbhishekKumar-mq1tt
    @AbhishekKumar-mq1tt 5 років тому +3

    Thank u for this awesome video

  • @MrPlaiedes
    @MrPlaiedes 6 років тому +1

    Nicely done sir!

  • @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!

  • @SimPwear84
    @SimPwear84 4 роки тому

    Outstanding Content, subbed!!

  • @cristiangutierrezdev
    @cristiangutierrezdev 5 років тому +1

    My Crocodile says thanks for this video!!

  • @MistaT44
    @MistaT44 5 років тому

    Amazing video! thanks

    • @hswolff
      @hswolff  5 років тому

      You are welcome!

  • @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!

  • @DanelonNicolas
    @DanelonNicolas 6 років тому +1

    we learn a lot! thanks!

    • @hswolff
      @hswolff  6 років тому +1

      Woohoo! Glad to hear!

  • @fsr_bu
    @fsr_bu 4 роки тому

    This is so dope! Thanks.

  • @lotfiholmes6397
    @lotfiholmes6397 5 років тому +4

    Be ready gas station people, I'm coming.
    Thanks for the video!

    • @hswolff
      @hswolff  5 років тому

      Haha, thanks!

  • @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.

  • @fadfooood
    @fadfooood 6 років тому +1

    Nice video. Does this work with Chrome redux extension?

    • @hswolff
      @hswolff  6 років тому +3

      It does not. It looks like Redux and acts like Redux...but it's not Redux...

    • @chethelesser
      @chethelesser 5 років тому

      @@hswolff quack

  • @tslqs
    @tslqs 4 роки тому

    Thanks, this is awesome

  • @les2997
    @les2997 6 років тому

    Why is the reducer using immutable data? Is this required for hook reducers?

    • @cornoc
      @cornoc 6 років тому

      redux.js.org/faq/immutabledata#why-is-immutability-required-by-redux this talks about redux but the reasoning is probably the same

    • @les2997
      @les2997 6 років тому

      @@cornoc This is Redux though where you need to support time travel.

    • @les2997
      @les2997 6 років тому

      @@cornoc I just asked Dan Abramov this question:
      Q: Can the reducer in useReducer mutate the state? I know in Redux state should not be mutated, but this question is about the reducer in hooks.
      A: No, it shouldn’t. (You can use Immer though)

    • @cornoc
      @cornoc 6 років тому

      @@les2997 it's not just for time travel, read the full explanation

    • @les2997
      @les2997 6 років тому

      @@cornocYou are still taking about Redux. I'd like to know why immutability is important for Hooks. Dan wrote that the Hooks reducer should not mutate the state, but I'm not clear why.