Create A Custom Hook in React | React Hooks Tutorial

Поділитися
Вставка
  • Опубліковано 1 гру 2024
  • In this video I go over how to create a custom hook in create. We utilize 2 examples for this: A Random Color Generator, and A UseQuery Hook.
    -
    🚀 Learn ReactJS By Building 6 Projects: codedamn.com/l...
    💻 PedroTech Discord: / discord
    -
    Social
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    Website: machadopedro.com
    Twitter: / pedrotech_
    Linkedin: / machadop1407
    Instagram: / _pedro.machado_
    Github: github.com/mac...
    Email: machadop1407@gmail.com
    Equipments I Use:
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    🌟 Algorithm Book To Pass Coding Interviews: amzn.to/2Z2CirS
    🌟 Microphone: amzn.to/2MKAm4V
    🌟 Keyboard: amzn.to/3tvU6ZR
    🌟 HD Webcam: amzn.to/3tMpJPD
    🌟 Room LED Lights: amzn.to/3a5mFGp
    Tags:
    Custom Hooks
    Fetch
    ReactJS Tutorial
    ReactJS and MySQL
    NodeJS Tutorial
    API Tutorial

КОМЕНТАРІ • 46

  • @codebreakthrough
    @codebreakthrough 2 роки тому +1

    congrats on reaching your 10K subscriber goal!

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

      Thank you so much Caleb! I remember watching your old c++ vids and I really liked them, glad to see you here!

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

    this video was clean srsly watched bunch on this topice but this is most clear

  • @k303k
    @k303k Рік тому

    Really appreciated for your efforts for making videos.Thanks a lot .

  • @tomasgilamoedo8301
    @tomasgilamoedo8301 2 роки тому +1

    Great explanation Pedro! keep on moving brobro, u reaching 50k soon! 🙌

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

    Very good.! Of all the videos I've watched, this explains in all in a simple and clear term

  • @CuteCreeperYT
    @CuteCreeperYT 3 роки тому +2

    Excellent work you've put up there Pedro.
    I mean this is just everything, if the basic is clear, complex logic can be implemented with much less efforts.

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

    A good starting point to learn custom hooks! thank you

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

    You are amazing dude . Keep going man❤️🤝

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

    thank u , i finally learn how to write custom hooks

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

    Congrats on reaching your 10k subscriber goal
    (I think I was number 30-something thousand subscriber)

  • @abhaytiwari6411
    @abhaytiwari6411 3 роки тому +1

    I admire your work

  • @maxmaksum4673
    @maxmaksum4673 3 роки тому +1

    great as always..thank you

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

    Thanks so much bro for the wonderful explanation with simple code implementation. You just saved me

  • @khandoor7228
    @khandoor7228 3 роки тому +4

    Excellent work Pedro, I like the simple example followed by a real world example, good technique.

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

      Glad you liked it! I am trying out different styles of tutorials!

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

    Perfect tutorial!

  • @lokmanlife3023
    @lokmanlife3023 3 роки тому +1

    Awesome as always. I got a question not related to this video. Its regarding the login system. Do you have a video on if the user login, will redirect to a profile page which show the logger info? if you dont, can you make a video on this topic? thank you..

    • @PedroTechnologies
      @PedroTechnologies  3 роки тому +2

      Thank you! I have a video on redirecting in React, however to display users information you just have to keep the users id and pass its id through a state or a prop.

  • @khandoor7228
    @khandoor7228 3 роки тому +1

    what would you recommend either custom hook as described here, useSWR or React Query?

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

      I would recommend React-Query for most intermediate to hard projects. But if you are building something huge that will have thousands of lines of code, maybe creating ur custom fetcher is better cause you have more control over it!

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

    Thank you 👍🏼❤️🙏

  • @chinthana
    @chinthana 3 роки тому +1

    Great video.. Thanks..

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

    I think you need to check response before putting img src like `response?.image` request usually takes time.

  • @Pareshbpatel
    @Pareshbpatel 2 роки тому +1

    Excellent Tutorial on React Custom Hooks. I found it very useFul ;-) - Thanks, Pedro
    {2022-02-14}, {2023-07-12}

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

    If you used that hook multiple times in your code wouldn't you need to destructure it to a different variable everytime?
    Example you have 'response' but if you copied and pasted that multiple times like you did at the end wouldn't it give an error? I'm assuming you would need to make the first usehook variable response then the second like response2 etc. Am I correct about that?

  • @JamesSmith-yj7wq
    @JamesSmith-yj7wq 2 роки тому

    Passing the request to useQuery is causing the axios to run the api request twice.. if you call the axios request from useQuery and only pass in the url to fetch, the api will only run once..

  • @eduardolopes1270
    @eduardolopes1270 2 роки тому +2

    Opa Pedro
    Cara, como que tu estudou inglês? Não lembro de ter ouvido uma pronuncia tão boa e uma fala tao fluida vindo de um BR. Abraços

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

      Boa Eduardo! Eu tive a sorte de poder estudar em uma escola internacional desde cedo, por isso tenho uma pronuncia melhor que o normal kkkkkk mas obrigado por ver os videos :) Abraços

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

    I don't know it's just giving me a blank page. Without creating a custom hook it just wrote the same code as you and tried to run it.. it created a button when ever I click on it it doesn't change color and tried creating a custom hook now it just gives me a blank page not sure why...

  • @Lohitpant
    @Lohitpant 3 роки тому +1

    Thanks. Completed it and after seeing so many Indian dishes, I am hungry.

  • @chinthana
    @chinthana 3 роки тому +1

    Can U just extend this video.. Where we need to get two values.. {loading: true, data:{}} ====> before loading.. And after loading ==> {loading:false, data:{real data fetched }}...
    If possible can U make video in future? 🙂

  • @DeepakGupta-pz4fx
    @DeepakGupta-pz4fx 3 роки тому +1

    Please make on video complete hook series

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

    how can I buy you coffee? Thank you for this.

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

    use custom hook starts 9:45

  • @teneshvignesan6227
    @teneshvignesan6227 Рік тому

    Not a big deal but if you ever making a tutorial, you don't have to speed rush. Try to be slower when explaining if not this is pointless in my opinion, although respect for you effort to help others.