Save Hours Of Work With These 5 Custom React Hooks

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ค. 2024
  • There are infinite possibilities for React hooks, but not all hooks are created equal. In this video I will be going over 5 incredibly powerful hooks that you can use in any project that are also super quick to implement.
    📚 Materials/References:
    GitHub Code: github.com/WebDevSimplified/u...
    Part 1: • 5 Custom React Hooks Y...
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    00:29 - usePrevious
    02:20 - useStateWithHistory
    06:33 - useStorage
    09:06 - useAsync
    11:18 - useFetch
    #ReactHooks #WDS #React

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

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

    Holy shit. This video is pure gold. Hats off to you Kyle !!!

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

    These hooks are wild. Absolute GOLD.

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

    Awesome Kyle. Love these useful practical custom hook tutorials!

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

    I wish you can make a video on when to make something as a component, when to refactor, like clean code for react. I face problems like this sometimes when two things have the exact same display like a big table for example but one displays one product and the other has to display an infinite amount based on user selection

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

    Great job brotha, waitin for Part 3 ⭐⭐⭐

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

    Kyle. You deserve a monument dude. For real.
    At least a damn trophy. Legend.

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

    These 5 are a lot better than the first 5. Thanks.

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

    These hooks are pretty cool. Definitely going to be using them in the near future.
    I have one question though. In the useCallback ( callbackMemoized ) of the useAsync, do you think you could have used an useReducer hook, instead of 3 useState hooks? This way you would call only one state change before running the callback function.

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

    Thank you so much Kyle. Keep doing the good work

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

    Definitely, going to be using these. I’ll need to modify the useStorage to also allow creating cookies but other than that, this is a game changer

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

    when i started to familiriaze my self to js and react , this is my go to channel thumbs upp

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

    Brilliant stuff, thank you

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

    Thanks Kyle, I like ideas a lot. Thank You!

  • @igors.2943
    @igors.2943 2 ปีที่แล้ว

    Thank you! Great content! :)

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

    Except for useFetch, all these hooks are already available through react-use, why not point at their git repo ? I guess the point is to have a better understanding of how thins work under the hood using your own refactored version ? Anyway, that is still relevant to be aware of those helpers, thanks for your work!

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

      With all the talk around external deps causing security problems, it's probably better to not have external dependencies for things you can (reliably) implement on your own. And yes as you mentioned, the learning process is important too.

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

      Good resource. It's always a good idea though to be able to implement this yourself so you can modify them to your needs since no two projects are the same.

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

      Hello thanks I didn’t know react-use exist it looks really cool but I think here he want you to understand what happening exactly and that’s how you make progress and be able to implement only what you need ( you will probably never use all on them)

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

    amazing video sir i learn something new today

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

    Thanks for sharing

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

    You are a king. Thank you sir.

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

    Thanks, appreciated

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

    My favorite channel lately. Although this video was too confusing for me. Going back to your useReduce video.

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

      I've been watching these custom hook videos and it feels like he is way too fast at explaining them for a newbie. Or then I am just too slow in the head

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

      @@Zechey everyone is stupid. It's ok.

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

    Thanks Kyle.

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

    hi kyle -- can you do a series on typescript?

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

    I've never had a very handsome guy taught me how to code. :)) Definitely make it easier to digest what's been taught.

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

    this dude is great with react hooks

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

    Wow complicated. Need to spend more time going over the custom hooks because there's a lot going on here.

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

    ty

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

    this is a banger video, the title is not clickbait at all. this will save me hours.

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

    THIS IS 🔥

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

    excellent 👍👍

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

    I am building a responsive webpage which has a form on it in the form the first and last name fields are on the same line when the page gets narrower the input field for last name wraps down but the label does not then as it gets narrower the label will wrap is there anyway to make the label and input rap at the same time?

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

    thanks bro

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

    Hello, thanks for the video. You probably have a mistake in useStorage hook
    if (typeof initialValue === 'function') {
    there is no initialValue, may be u wanted to use it like this:
    if (typeof defaultValue === 'function') {
    Thanks

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

      I was thinking the same I dont see any "initialValue" in the file

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

      I guess he meant defaultValue instead of initialValue

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

    Hi. Any reason why useRef is used so much in these functions? I noticed that most places the refs usually just store the state and you are changing it by assigning a new value to the ref.current. why so?

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

      I guess its because changing ref.current doesnt cause a rerender yet it stores the value.

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

    amazing

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

    Hi Kyle. When you create a custom hooks you wrap every method into a useCallback. Afterwards you are returning a new object every time the hook rerenders (without useMemo it will get a new object every time). This is probably not what you want, correct? I would suggest adding a useMemo arround the returning object (or array) or am I wrong?

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

      @@agenticmark I think you did not get that correct. I mean to use an additional useMemo to the returning object, not the functions itself.

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

    omg React is so good... and kyle is so good at it

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

    Nice video Kyle but I have a question
    How can I use "useFetch" in a button click event
    I mean when I clicked the button then it'll run the "useFetch"

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

      You can't use the hooks inside the function

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

      But you can rewrite the useFetch function, so it will return also a handleFetch function, that could be passed to button as onClick.

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

    10:18 why useffect Is doing here? Why it wraps useCallback?

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

    thinking about using TS maybe? I think it'd not hurt people who even don't want to use it themselves to have some basic types in there...

  • @HabiburRahman-uy6qv
    @HabiburRahman-uy6qv 2 ปีที่แล้ว

    I like it

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

    i cant understand what {capacity = 10 } = {} means like why are we doing = {} can someone please explain

  • @HabiburRahman-uy6qv
    @HabiburRahman-uy6qv 2 ปีที่แล้ว

    I understand you

  • @HabiburRahman-uy6qv
    @HabiburRahman-uy6qv 2 ปีที่แล้ว

    I like it and you too

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

    if (typeof initialValue === 'function') shouldn't be if (typeof defaultValue === 'function')?

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

    Would useStateWithHistoryWork event with "value" being a function ? .... I mean history would not be an array of numbers or strings but an array of functions

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

      Could use JSON.stringify(function) to store it as text anyway. Then JSON.parse(function) to use it.

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

      @@aliphian hmm, JSON.stringify(function) always returns an undefined ... so this would not work I suppose

  • @braham.prakash
    @braham.prakash 2 ปีที่แล้ว +1

    This video made me feel like i knew nothing 😭😭

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

    Thank you very much for the excellent training
    Please teach us how to upload a site when we write it
    And how to design a site-specific email form and send that email to all the company's customers

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

    Can you make a hook for detecting browser back and forward button click.

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

    👍

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

    Not an react hooks, BrainHeater hooks . Its so much complicated to understand

  • @igors.2943
    @igors.2943 2 ปีที่แล้ว

    export default function usePrevious(value) {
    const previousRef = useRef()
    useEffect(() => {
    previousRef.current = value
    }, [value])
    return previousRef.current
    }
    isn't it the same but simpler?

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

    This guy isn’t human

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

    Hey, does anyone want to work on something? I'm really looking for beginner programmers like myself to build anything. Maybe a really simple frontend of a website or even a tiny react application comment below. I just really want to collaborate with random people on something and see what that's like

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

    not so simple 4 me

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

    I feel so stupid, cause have no idea where do we need all these custom hooks with a bunch of code inside it

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

    Man, you speak so fast!

  • @HabiburRahman-uy6qv
    @HabiburRahman-uy6qv 2 ปีที่แล้ว

    Kile hey

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

    3rd

  • @HabiburRahman-uy6qv
    @HabiburRahman-uy6qv 2 ปีที่แล้ว

    Kyle

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

    666 000 to oktober

  • @thecutedreamkostasp.4449
    @thecutedreamkostasp.4449 2 ปีที่แล้ว

    Didnt know u could use a hook inside a function and not just in top lvk! Wth!!!

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

      that resulting function is a custom hook

    • @thecutedreamkostasp.4449
      @thecutedreamkostasp.4449 2 ปีที่แล้ว

      @@aravindmuthu5748 yeai know! It doesnt mater is a custom hook! I have tried doing that similar with a custom hook and didnt let me

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

    You are beautiful!

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

    fuck..

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

    amazing