Learn Custom Hooks In 10 Minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 192

  • @yanivgk
    @yanivgk 4 ปีที่แล้ว +68

    I'm usually not using custom-hooks because I lack the imagination where to use them, and video just gave me 2 great ideas, thanks ! :)
    It would be great if you could do more videos regarding different common custom-hooks like these ones.

    • @chhavimanichoubey9437
      @chhavimanichoubey9437 ปีที่แล้ว +1

      Yup, I think we don't have the coders' minds YET!!! or maybe we need to throw ourselves into the fire of a working environment to get creative and find use cases of various programming concepts.

  • @krisnarusdiono1304
    @krisnarusdiono1304 2 ปีที่แล้ว +10

    i have finished all this react hook series in this channel, literally worth every seconds. Thanks Kyle

  • @brian-lau
    @brian-lau 3 ปีที่แล้ว +134

    damm, i am hooked now

  • @MagiCityProductions
    @MagiCityProductions 2 ปีที่แล้ว +5

    You have the best tutorials. You never add a bunch of unnecessary commentary and for that I thank you.

  • @samartajshaikh2601
    @samartajshaikh2601 2 ปีที่แล้ว +1

    The way you explain it, i am in awe of it.

  • @wendylee5498
    @wendylee5498 3 ปีที่แล้ว +3

    It's worth taking note that the views counts for this series dropped from 216,154 views (1st video) to 42,597 views (last video), maybe means there 's a learning curve; and I am proud that I watched all and code along. Great work Kyle!!!

  • @ינוןאלבז-כ1ז
    @ינוןאלבז-כ1ז 2 ปีที่แล้ว +3

    You're really simplifying the web for me

  • @FaysalBDev
    @FaysalBDev 2 ปีที่แล้ว +2

    this video is so underrated, it should have like a billion likes. thank you

  • @aubidanaalwa4161
    @aubidanaalwa4161 3 ปีที่แล้ว +2

    you are one of the best that explains, thanks a lot for all the useful information

  • @dannnnydannnn5201
    @dannnnydannnn5201 3 ปีที่แล้ว +7

    Great series. You really helped me figure out the difference between the different types of react hooks. I was not having the easiest time trying to figure it out looking through other people's code. Thanks man. Keep the videos coming. You're great at what you do!

  • @deepanjii2009
    @deepanjii2009 4 ปีที่แล้ว +7

    Wow man. You really have made the web simplified for us to build our project. Awesome content as always👏

  • @paccioti
    @paccioti 4 ปีที่แล้ว +30

    React and hooks are so freaking fun. I just got my first job as dev and first task was creating a frontend all with hooks, apollo graphql, typescrypt and redux. When you figure it out you can play around with data really nicely. PS great channel

  • @kamelowy
    @kamelowy 2 ปีที่แล้ว +2

    useLocalStorage hook should be implemented in React by default, it makes the operations on local storage so clean i can't imagine doing it the "default" way again. Thanks for another great tutorial! :)

  • @Kilopillz
    @Kilopillz 3 ปีที่แล้ว +1

    Please keep this up this is really great. I just finished your entire hooks Playlist. Thank you😊

  • @NovaMenteMedia
    @NovaMenteMedia ปีที่แล้ว +1

    Thanks so much for these videos, they are very concise and easy to follow.

  • @fkbey5756
    @fkbey5756 ปีที่แล้ว

    i use redux toolkit and it helps me a lot. but really thanks for the video. we love u

  • @faris.abuali
    @faris.abuali 2 ปีที่แล้ว +1

    Thanks for simplifying react for us!

  • @bohdanromanovich4912
    @bohdanromanovich4912 3 ปีที่แล้ว +1

    Your video's is awesome. It's so simple to understand what you are saying! Thank you so much!

  • @titlisarkar278
    @titlisarkar278 4 ปีที่แล้ว +1

    Thanks Kyle... These videos are really helpful for beginners.

  • @yashdefy
    @yashdefy 2 ปีที่แล้ว

    I am "hooked" to this channel..

  • @BeCurieUs
    @BeCurieUs 4 ปีที่แล้ว

    This example is perfect for me! I was creating a React project to manage Arkham Horror LCG stuff, and just had to saved in a big ol state. But for saving games serverlessly, local storage was gonna be the way I handled it. This idea will meld in nicely with saving my data, woot!

  • @מיכלדרור-דשת
    @מיכלדרור-דשת ปีที่แล้ว

    best explanation ever!! thank you

  • @kostiantynkarzhanov9216
    @kostiantynkarzhanov9216 ปีที่แล้ว

    Great tutorial! Thank you for the explanation! 💛

  • @muhammadzeeshan07
    @muhammadzeeshan07 4 ปีที่แล้ว

    Superb kyle, every thing is clear

  • @gaatutube
    @gaatutube 3 ปีที่แล้ว

    Thanks for the great series on react hooks. Will definitely have to go through it a 2nd time to let all the details sink in. But I have good overview of it now.

  • @saurabhma123
    @saurabhma123 3 ปีที่แล้ว

    Greatly explained the concept!

  • @amiturfnd
    @amiturfnd 4 ปีที่แล้ว +2

    Thanks a lot for this video. learnt something new today :)

  • @MaxProgramming
    @MaxProgramming 4 ปีที่แล้ว +1

    Thank you! This is very much simplified to me!

  • @VishalSharma-rn7mt
    @VishalSharma-rn7mt 3 ปีที่แล้ว

    Awesome explanation, genius guy

  • @parasmaniseth7873
    @parasmaniseth7873 3 ปีที่แล้ว

    Before knowing this...I also use to the same thing....saving things in local storage....today he made this a react custom hook
    Kyle do knows how to use his tools appropriately and in efficient way

  • @madhusudhan4001
    @madhusudhan4001 4 ปีที่แล้ว

    i have three letters for this video WTF ---- hands-down best explanation of custom hooks... thanks Kyle.

  • @oskarmarkin5674
    @oskarmarkin5674 4 ปีที่แล้ว +17

    TH-cam should make a two like button only for your channel because I would give you two likes

  • @rohitborra2507
    @rohitborra2507 ปีที่แล้ว

    really great tut. thanks dude

  • @arunbm123
    @arunbm123 2 ปีที่แล้ว

    very nicely explained

  • @akashdevgan
    @akashdevgan 3 ปีที่แล้ว +2

    One question, why will initialValue be a function?

  • @moiserwibutso4899
    @moiserwibutso4899 2 ปีที่แล้ว

    Thanks for this great tutorial.

  • @boses5320
    @boses5320 2 ปีที่แล้ว

    This was a great example... However if this example would help to stay login in after refreshing ..would be great

  • @YRS24
    @YRS24 3 ปีที่แล้ว

    awesome learnt about local storage and hooks

  • @liamcao-j6y
    @liamcao-j6y 2 ปีที่แล้ว

    thx already shared to Twitter

  • @SumitKumar-bu3yn
    @SumitKumar-bu3yn ปีที่แล้ว

    Thank you

  • @DeepakGupta-hj2dv
    @DeepakGupta-hj2dv 4 ปีที่แล้ว

    Great explanation kyle ..please make on one video Event loop

  • @snaplu4683
    @snaplu4683 4 ปีที่แล้ว

    great tutorial series, thank you so much

  • @manibarathi08
    @manibarathi08 3 ปีที่แล้ว

    You can even add a deleteItem function inside useLocalStorage to delete the item if the user needs to

  • @SS-re8xb
    @SS-re8xb ปีที่แล้ว

    Is "if(initialValue instanceof Function) return initialValue();" necessary? Because if using a console.log() to print out whether it's true or false, we'd always get "false". So, what's the reason to use this line of code?

  • @EJIqpEP
    @EJIqpEP 4 ปีที่แล้ว

    Hi Kyle, I really like your videos and the quality of the image. What camera are you using? Thanks!

    • @WebDevSimplified
      @WebDevSimplified  4 ปีที่แล้ว

      It is a logitech brio shooting in 1080p

    • @EJIqpEP
      @EJIqpEP 4 ปีที่แล้ว

      @@WebDevSimplified Thanks a lot!

  • @kikiken4287
    @kikiken4287 2 ปีที่แล้ว

    Thanks for the good video!
    But I think your useTimeout function should be like something like below.
    export function useTimeOut(callback, delay, dependency) {
    const callbackRef = useRef();
    const timeOutRef = useRef();
    useEffect(() => {
    console.log('callback update');
    callbackRef.current = callback;
    }, [...dependency]);
    ...
    }
    because like you mentioned, callback without 'useCallback' is different always.

  • @tgfassina
    @tgfassina 28 วันที่ผ่านมา

    Thanks!

  • @zlackbiro
    @zlackbiro 4 ปีที่แล้ว +1

    Now, why not to bring this to another level? build your custom hook useStateStore, then create useReducer inside, import store hook into your components and voila, you have global store like Redux. Also, you can privide that store using context api... :)

  • @juliangzr4998
    @juliangzr4998 3 ปีที่แล้ว

    Thank you very much! great video

  • @nahida4444
    @nahida4444 2 ปีที่แล้ว

    Hey, a question, does a hook persist and share the state through multiple component, like context-provider works?

  • @omarbarra3456
    @omarbarra3456 ปีที่แล้ว

    amazing, thanks

  • @l.e.nichols9382
    @l.e.nichols9382 3 ปีที่แล้ว

    This is awesome, thanks so much.

  • @rohandevaki4349
    @rohandevaki4349 3 ปีที่แล้ว

    actually i tried the same code with a signle function , in the same component, and it works fine, but i cant use useEffect inside a function,for that i just made a if check,
    and if we want to use a useEffect inside a function, that must be a react component, or a custom hook, that is fine, but here the important thing is with a custom hook we can use it several times, instead of writing the code again and again, thanks for the awesome video,

  • @dmcshehan
    @dmcshehan 4 ปีที่แล้ว

    Thanks a lot for the video.

  • @krishnayele5639
    @krishnayele5639 4 ปีที่แล้ว

    liked it, loved it, just the thing I was looking for. Thanks very much.

  • @ВадимАлекс-щ6ъ
    @ВадимАлекс-щ6ъ ปีที่แล้ว

    thanks!

  • @diegoburlandotheinformal1217
    @diegoburlandotheinformal1217 3 ปีที่แล้ว

    Good job man!

  • @vinaykumar-sg7xd
    @vinaykumar-sg7xd 3 ปีที่แล้ว +2

    how can initialvalue be a function. i didn't get that part. can anyone explain please

  • @Pareshbpatel
    @Pareshbpatel 2 ปีที่แล้ว

    Great Tutorial on Custom Hooks in React. Thanks, Kyle
    {2022-02-24}, {2022-08-02}, {2022-11-16}, {2023-06-28}

  • @duchoang1074
    @duchoang1074 2 ปีที่แล้ว

    Hello, it's fun to write a custom hook, but I wonder if this custom hook is better than Redux or the same, or worse?

  • @ngocdangduc3772
    @ngocdangduc3772 ปีที่แล้ว +1

    Can some1 explain to me why using a function in useState can help reduce the call on localstorage ?😊

  • @caesarbala
    @caesarbala 2 ปีที่แล้ว

    so custom hooks combination of function and component we take argument and return / without return . also we can useEffect within it .

  • @basiccodingwithadam8125
    @basiccodingwithadam8125 4 ปีที่แล้ว

    Great little video, as usual, Kyle.

  • @BharatSingh-zk8lx
    @BharatSingh-zk8lx 2 ปีที่แล้ว

    this would definitely be helpful in react native
    😀

    • @priyankaroberts1093
      @priyankaroberts1093 2 ปีที่แล้ว

      Hey Bharat
      Have you built any react projects recently? Are you open to internship/job opportunities in software development ?

  • @riyajha6500
    @riyajha6500 4 ปีที่แล้ว

    thanks, sir for such awesome video, if you possible please make some videos on react recoil.

  • @anasalhariri5474
    @anasalhariri5474 2 ปีที่แล้ว

    Kyle, how do you get the localstorage in chrome to update when the state is changing? I had to refresh the localstorage to see the new value. Can you please help?

  • @omarbarra3456
    @omarbarra3456 ปีที่แล้ว

    just a little improvement, for the the custom hook we can use named-parameters, in that way the order of the parameters does not matter.

  • @muonx9649
    @muonx9649 3 ปีที่แล้ว

    It just works!

  • @thivatutorials4040
    @thivatutorials4040 ปีที่แล้ว

    nice bro thanks for giving this video

  • @bryceblazegamingyt9741
    @bryceblazegamingyt9741 ปีที่แล้ว

    Imagine getting hearted by one of the best teachers on the internet

  • @randyfix3546
    @randyfix3546 3 ปีที่แล้ว

    Why on the useEffect does React complain about ' key ' being a missing dependency? I've seen this in a couple tutorials now, has something changed with React?

  • @daniillitvinenko4348
    @daniillitvinenko4348 ปีที่แล้ว

    Can someone explain what he does starting 5:02? "And now we what we can do is use a function version...". As opposed to what? Does writing an explicit return statement make it a "function version"?

  • @shuuheihisagi3148
    @shuuheihisagi3148 4 ปีที่แล้ว

    Hey, thanks again for another video! Can you make on related to wherr to store jwt on the client side?

  • @goodToBeConfidential
    @goodToBeConfidential 10 หลายเดือนก่อน

    whats the configuration of your computer?

  • @rohinchopra9812
    @rohinchopra9812 3 ปีที่แล้ว

    Even though how simple the last hook was it can be pretty handy in debugging stuff

    • @priyankaroberts1093
      @priyankaroberts1093 2 ปีที่แล้ว

      Hey Rohin
      Have you been working on any react projects currently? Are you open to internship/job opportunities in software development ?

  • @ernestomotta5178
    @ernestomotta5178 4 ปีที่แล้ว

    Awesome, thank you

  • @ridl27
    @ridl27 4 ปีที่แล้ว

    ty.

  • @Kats0unam1
    @Kats0unam1 4 ปีที่แล้ว

    Do you have a course with Hooks + Redux ?

  • @syedalimehdi-english
    @syedalimehdi-english 3 ปีที่แล้ว

    I don't understand, why don't we use useRef instead of useState?
    We could prevent un necessary re-renders right?

    • @kinstar
      @kinstar 2 ปีที่แล้ว

      He used usestate so he could log and show the input changing on each keystroke, he needs the re render for that

  • @ajbotha7232
    @ajbotha7232 3 หลายเดือนก่อน

    Wow thanks

  • @MrXperx
    @MrXperx 3 ปีที่แล้ว

    Mind blow video

  • @meowmeow21588
    @meowmeow21588 2 ปีที่แล้ว

    great video, but I don't get why the input wouldn't be persisted in the first place. Isn't the value of the input field the useState "name," whose value would persist through refreshes? So after you type something in and set the useState to that input, after a re-render why wouldn't the input just reset it value to the useState value that's still there? Thanks a ton

    • @joleDEV
      @joleDEV ปีที่แล้ว

      Because a rerender is not the same as a reload

  • @rogerjohn7786
    @rogerjohn7786 4 ปีที่แล้ว

    Hi Kyle please make a video on Instant search filter like youtube on react.

  • @amankaushik5833
    @amankaushik5833 4 ปีที่แล้ว

    Really, really awesome video!! as always by the way I wanted to ask that can we make android apps in like plain javascript without using React Native and can we use js with C++ or python?Thanks!!

    • @prabhatchanchal
      @prabhatchanchal 4 ปีที่แล้ว

      I know one way to use js with python is "eel" but not don't know about C++ with js.

    • @fredhair
      @fredhair 4 ปีที่แล้ว

      Android supports c++ natively and has its own NDK but why you'd want to mix it with js im not sure. PWA is basically using js and c++ just the c++ is written by the browser vendor. Its all possible but the practicality of it will depend on the kind of software you want to write.

    • @amankaushik5833
      @amankaushik5833 4 ปีที่แล้ว

      @@fredhair hey there!! actually, I was thinking that it would be easier to make a user interface if we combine c++ with js, HTML, AND CSS maybe Node js would do it.

  • @KTHoopLife
    @KTHoopLife ปีที่แล้ว

    I don't get why "useUpdateLogger" needs to use useEffect at all? Since it's prop/input parameter is constantly changing, why do you need useEffect?

  • @ayushilahariya6477
    @ayushilahariya6477 ปีที่แล้ว

    hello i have one question
    i want to use the usedispatch and useselector outside the function and class component. i have a helper.js in which i am trying to call the api by using redux saga for that i need to use usedispatch and then the response i want to get through useselector in same helper class. any idea how to achieve this

  • @joedu7320
    @joedu7320 ปีที่แล้ว +1

    Can someone please explain: why assign a function in useState will reduce the call of localstorage, like he said in 5:20, "only call this once when first time rendering the component, not everytime render". I mean this function in useState still returns the result of function savedValue, so why not write like const [value, setValue] = useState(savedValue(key, initialValue)) ? Can anyone explain it?

    • @archdetective
      @archdetective ปีที่แล้ว +1

      I don't know if you already found your answer, but just in case...
      When using a function as initial value for useState, we need to practice "CURRYING" or wrapping function executions in another function, like this:
      useState(( ) => someFunc( ))
      as opposed to just: useState(someFunc( )).
      This way, someFunc doesn't get called unnecessarily every re-render. It's not noticeable on small apps but treat it as an optimization with the way useState hook works. In the video, the data from local storage is only read at the initial component render.
      EDIT: Try putting a console.log( ) on the function and compare. The one with no currying will show the log every keystroke.

  • @kefistefi
    @kefistefi 2 ปีที่แล้ว

    Is there a way to change the key somehow, since I would love to have mutliple keys for every users that let's say loggs into my page.

  • @tomermatmon
    @tomermatmon 4 ปีที่แล้ว

    This is great!

  • @kirankamath5891
    @kirankamath5891 ปีที่แล้ว

    Can i say custome hooks have the same purpose like HOC in class component.

    • @shadman1820
      @shadman1820 ปีที่แล้ว

      render props and hoc do the same kind of thing i guess

  • @fluttterdev1k
    @fluttterdev1k 2 หลายเดือนก่อน

    I ate these fucking hooks bcz of you, the great Kyle

  • @rohandevaki4349
    @rohandevaki4349 3 ปีที่แล้ว

    at 1:19, what is the alternative for localstorage?, can we use useContext or redux for global storage, or even though if we use useContext or redux, the input value will become empty?

  • @iurii7752
    @iurii7752 4 ปีที่แล้ว

    Great, thank you :)

  • @willmakk
    @willmakk 4 ปีที่แล้ว

    love me some cutsom hooks

  • @abdullahawisimulaha
    @abdullahawisimulaha 4 ปีที่แล้ว

    Why to create useUpdateLogger if you just can write console.log(value)?

  • @mr-moses-01
    @mr-moses-01 2 ปีที่แล้ว +1

    Dude how are you making your hair like that every day :D

  • @PastaInformatyki
    @PastaInformatyki 4 ปีที่แล้ว +3

    In getSavedValue function: "if (savedValue) return savedValue" What if savedValue is false or 0 or an empty string? Shouldn't it be like: "if (savedValue !== null) return savedValue" or am i mistaken?

  • @justinmlawrence
    @justinmlawrence 3 ปีที่แล้ว

    Awesome!

  • @Human_Evolution-
    @Human_Evolution- 3 ปีที่แล้ว +8

    So lost. I cannot follow this video. Does anyone know of something even easier than this? I am like 10 hours into these and I feel like I know nothing.

    • @Viv-m8j
      @Viv-m8j 6 หลายเดือนก่อน

      Same here

    • @Human_Evolution-
      @Human_Evolution- 6 หลายเดือนก่อน

      @@Viv-m8j been a paid dev for over a year now. Still confused lol

  • @Neha-sw6ky
    @Neha-sw6ky 4 ปีที่แล้ว +5

    Amazing video. I'm in love with you!