Тёмный

React Custom Hooks: useDebounce - Simply Explained! 

Cosden Solutions
Подписаться 87 тыс.
Просмотров 23 тыс.
50% 1

Join The Discord! → discord.cosdensolutions.io
Source Code → github.com/cosdensolutions/co...
In this video we will learn about custom React hooks, starting with useDebounce. This is a powerful hook to use when you need to delay the updating of a value by a set amount of time. It's useful when you have a fetch being triggered by a input field and you don't want to fire a new request every time the input. We're going to see the problem, come up with a solution, and then use the custom useDebounce hook to fix it. Enjoy!

Опубликовано:

 

5 июл 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 72   
@cosdensolutions
@cosdensolutions 3 месяца назад
Hey everyone! I just launched 🚀 Project React, which is a course that teaches you React by building a real-world project. It goes way beyond what you see in these videos and walks you through step-by-step on how to build a big and complex application with React! You can check it out here: cosden.solutions/project-react
@codingispower1816
@codingispower1816 7 месяцев назад
Dude, if you made a full react course with testing and all of the adv concepts, i'd pay for it. Your teaching styleis clear and concise and you don't gloss over the important parts AND you did it in TS? Sheesh. Legend.
@cosdensolutions
@cosdensolutions 7 месяцев назад
Oh but I am making one :) stay tuned
@codingispower1816
@codingispower1816 7 месяцев назад
I can't wait!@@cosdensolutions
@sagardas4218
@sagardas4218 3 месяца назад
@@cosdensolutions Hey bro make Next Js + Typescript course
@user-eo1tc2sd9y
@user-eo1tc2sd9y Месяц назад
I hope you won't forget your youtube tagline which says "best react content on youtube" apart from paid course.
@GavHTFC
@GavHTFC 9 месяцев назад
Darius you lifesaver, I just knew when searching "react debounce" that you'd come up in the results, and that your solution would work! I wasn't approaching debouncing in the best way admittedly, and you've put me back on the straight and narrow, keep it up!
@cosdensolutions
@cosdensolutions 9 месяцев назад
damn, thank you for the kind words! really glad you find the videos useful!
@brandonyippp
@brandonyippp 25 дней назад
Seriously underrated channel, thank you so much for your continuous content!
@prashlovessamosa
@prashlovessamosa 10 месяцев назад
You are one of the finest teacher I have found on yt the way you explain stuff amazing thanks sir Excited for upcoming stuff.
@cosdensolutions
@cosdensolutions 10 месяцев назад
Thanks for the comment!
@MohammedShibincp
@MohammedShibincp 9 месяцев назад
I see a lot of videos on RU-vid, but I can’t understand anything. But in this video, I understand everything about custom hooks. thanks sir
@cosdensolutions
@cosdensolutions 9 месяцев назад
really glad to hear it!
@garikmelqonyan6011
@garikmelqonyan6011 9 месяцев назад
Good job, bro. Makes tons of sense
@hilkiahlavinier
@hilkiahlavinier Год назад
Nicely explained!
@letthesuntalk
@letthesuntalk 7 месяцев назад
really nice, I've been learning a lot from your videos.
@user-rr1hi1rd3s
@user-rr1hi1rd3s 9 месяцев назад
Thanks, you really hit the nail on the head
@igorbarbosa5331
@igorbarbosa5331 7 месяцев назад
Perfect explanation!
@ravisankarp61
@ravisankarp61 8 месяцев назад
Excellent and I loved ur videos and channel.
@amankriet
@amankriet Месяц назад
Thanks a lot. The debounce function was not working in React and now I know why and how to do it.
@katrin_awsm
@katrin_awsm 6 дней назад
Thank you very much! Very useful and understandable
@brNoMundo123
@brNoMundo123 5 месяцев назад
Eu amei o vídeo! ❤seu conteúdo é demais!
@_briantravis
@_briantravis 5 месяцев назад
Exactly what I was looking for :D
@_briantravis
@_briantravis 5 месяцев назад
what vscode theme are you using?
@kelvinnwachukwu8141
@kelvinnwachukwu8141 5 месяцев назад
This is awesome as your videos has helped me alot
@kelvinnwachukwu8141
@kelvinnwachukwu8141 5 месяцев назад
Please could you also do an example using lodash
@HojjatAfsharan
@HojjatAfsharan 9 месяцев назад
Perfect tutorial! thanks
@cosdensolutions
@cosdensolutions 9 месяцев назад
yes you're totally correct!
@thatkannurgirl
@thatkannurgirl 4 месяца назад
So helpful ❤
@user-tu1lx6vz9p
@user-tu1lx6vz9p 11 месяцев назад
Nice Man great excellant
@MEET4RIDE
@MEET4RIDE 10 месяцев назад
Many Thanks!
@sunilmg723
@sunilmg723 11 месяцев назад
Thanks you so much bro ❤ nice explaination can you please do a detailed video on react virtualization
@chrishanthacosta4093
@chrishanthacosta4093 23 дня назад
good explanation bro..
@AbdelrahmanSameeh
@AbdelrahmanSameeh 4 месяца назад
nice work
@nfaical3
@nfaical3 6 месяцев назад
Thanks 👍
@icoderdev
@icoderdev Год назад
The is so much helpful, thanks so much.
@cosdensolutions
@cosdensolutions Год назад
🤙
@Andres-Estrella
@Andres-Estrella 17 дней назад
thanks !
@xgenious
@xgenious 3 месяца назад
useful tips
@helenasdiaries515
@helenasdiaries515 5 месяцев назад
cool thanks
@alvinacosta2312
@alvinacosta2312 8 месяцев назад
hello good sir, may i just ask the difference of adding 'search' as value prop for your input as compared to not using the value prop but still using setSearch in the onChange? is it the same or which one is better? thank you
@codingispower1816
@codingispower1816 7 месяцев назад
Can you do a video on Higher order components? You teach well.
@billyfigueroa1617
@billyfigueroa1617 5 месяцев назад
Great video. Typically in react we load all the users when we load the page so when we are doing a search we are searching through the state on the fronted Nowadays, this type of issue, seems to be more realistic in an older styled app but if I am wrong, please correct me
@gamersdepo3892
@gamersdepo3892 11 месяцев назад
Hey, your videos are so nicely explained, I just want to request you one thing, could you please make a explanation video about the MERN stack, and how much knowledge do we need to gain to land a job as the MERN stack developer? like in every field, react, express, mongodb, and node.
@cosdensolutions
@cosdensolutions 11 месяцев назад
the only thing is I'm more focused on React specifically for now, not dabbling too much into DB or backend stuff. Will do more of that once server components are more prominent in the industry 🤙
@AbsolutePain
@AbsolutePain 8 месяцев назад
Thanks ! The explaination was clear and crisp . Can you make a video on how to organize /file sturucture your api calls using tanquery || custom hooks . Can we have like only 4 custom hooks for crud api calls ? i just want to learn prod level things from you . Thanks for the great vid
@cosdensolutions
@cosdensolutions 8 месяцев назад
will add it to the list! But also, I'm currently working on a course that will build a big project meant for production, so there will be tons to learn there too!
@shub226
@shub226 10 месяцев назад
Easiest implementation of Debounce Search
@hrutikdhumal402
@hrutikdhumal402 10 месяцев назад
❤❤❤
@icoderdev
@icoderdev Год назад
@roanacedev
@roanacedev Год назад
❤❤
@matteo6056
@matteo6056 7 месяцев назад
Great videos, but isn't your useDebounce hooks same as Reacts useDeferred hook with possibility to set up timeout?
@cosdensolutions
@cosdensolutions 7 месяцев назад
yes, useDebounce is the same thing but works through a delay. useDeferredValue is handled automatically through React without a fixed delay
@jubyaid1235
@jubyaid1235 Месяц назад
what is the chat gpt add on being used?
@int0therain44
@int0therain44 4 месяца назад
Just a question. Isn't it better, to use import { debounce } from 'lodash'; ? it gave a lot of features. What is your opinion when looking at the documentation ? Thank !
@cosdensolutions
@cosdensolutions 4 месяца назад
You can, but it is a big library and if you don't use a lot of its functions, sometimes its easier to just write it yourself
@int0therain44
@int0therain44 4 месяца назад
@@cosdensolutions Thank for your reply ! I finally ended up using this : import { useDebounce, useDebouncedCallback, useThrottledCallback } from "use-debounce"; This is a light npm library in typescript.
@imadimad8814
@imadimad8814 6 месяцев назад
Can we use useRef hook to do the same thing
@jritzeku
@jritzeku 8 месяцев назад
Can you use useDebounce with formik ?Im currently having an issue where every keystroke in form field causes component to re-render like 2-3 times. Apparently it's a known issue with formik that is unresolved. Perhaps useDebounce can be used here.
@cosdensolutions
@cosdensolutions 8 месяцев назад
to do that, you would have to create your own input components that make use of useDebounce and manually update the state debounced! You could also try RHF as an alternative to Formik for better perf
@minhnguyendung4453
@minhnguyendung4453 Год назад
I hope you make a seri to teach async JavaScript (promise, async await,...) I don't understand how it's works
@cosdensolutions
@cosdensolutions Год назад
Will add it to the list!
@katejohnson6411
@katejohnson6411 7 месяцев назад
Why doesn't it trigger on the first letter "render", maybe I don't correctly understand exactly.
@cosdensolutions
@cosdensolutions 7 месяцев назад
Because it defers triggering until when the ms have elapsed!
@saqibmuhammad7218
@saqibmuhammad7218 10 месяцев назад
LOL❤‍🔥
@helenasdiaries515
@helenasdiaries515 5 месяцев назад
it says I cant accept the invite to discord(((
@cosdensolutions
@cosdensolutions 5 месяцев назад
it should work, maybe try a different browser?
@xthesly
@xthesly 8 месяцев назад
Hi, better use fetch abortion ?
@user-dd7kw3ym5i
@user-dd7kw3ym5i 5 месяцев назад
I wanna know why you used hooks in useDebounce? It works without them like this..... ********************************** let timeId; function useDebounce(functionToDelay, delay == 1000) { clearTimeout(timeId) timeId = setTimeout(() => { functionToDelay() }, delay); } export default useDebounce // then import the useDebounce and put it inside of the useEffect **********************************
@cosdensolutions
@cosdensolutions 5 месяцев назад
well, based on "// then import the useDebounce and put it inside of the useEffect", you're also using hooks. You basically have to use hooks to implement this
@user-dd7kw3ym5i
@user-dd7kw3ym5i 5 месяцев назад
@@cosdensolutions I mean there's no hooks inside the body of my example
@StephenArpad
@StephenArpad 7 месяцев назад
In my case, I've more than one input compnent. In one I type, let's say, the "Zip Code", In the one, I type in the "Street Address", With this I mean, that I need 2 inputs here, so my call to the API can take place.. However, when implementing this functionality, I get instead: *Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency arrar, or one of the depdendecies changes on every render* Has anyone experienced this scenario already? What solution did you apply?
Далее
Learn React Hooks: useCallback - Simply Explained!
17:15
OVOZ
01:00
Просмотров 727 тыс.
3M❤️ #thankyou #shorts
00:16
Просмотров 3,9 млн
Custom Hooks in React (Design Patterns)
12:56
Просмотров 34 тыс.
Don't Use React Context!! Use This instead
13:34
Просмотров 26 тыс.
Every React Concept Explained in 12 Minutes
11:53
Просмотров 426 тыс.
You might not need useEffect() ...
21:45
Просмотров 152 тыс.
Why Signals Are Better Than React Hooks
16:30
Просмотров 457 тыс.
Learn React Hooks: useMemo - Simply Explained!
13:41
Просмотров 81 тыс.
The correct way to optimise React
11:29
Просмотров 30 тыс.
OVOZ
01:00
Просмотров 727 тыс.