Learn useImperativeHandle In 10 Minutes

  Рет қаралды 70,043

Web Dev Simplified

Web Dev Simplified

Күн бұрын

Пікірлер
@BB_Harunya
@BB_Harunya Жыл бұрын
Short, concise, no fluff, effective examples Where do we pay this guy
@sainathreddy1950
@sainathreddy1950 Жыл бұрын
There is an option super thanks just below the video. you can pay him using it.
@jingyazeng5834
@jingyazeng5834 2 ай бұрын
Clear explanation and super helpful use cases. THANK YOU!
@feynthefallen
@feynthefallen 2 жыл бұрын
You know, I have used useImperativeHandle, I've used useRef, I've used forwardRef, but only because somebody told me "do it that way". I'd be mighty grateful if some day you posted a deep dive into Refs course that goes into the nitty-gritty of the concept of the humble ref and explains in detail what they are and how they are implemented. I found your video on the inner workings of Promises extremely helpful. Maybe you can do something similar for refs.
@utkarshagrawal3640
@utkarshagrawal3640 2 жыл бұрын
But don't u think there isn't much to refs, u already know the concept right?
@Bluesourboy
@Bluesourboy 2 жыл бұрын
I've always thought of useRef like a smart container that always contains the thing you put in it because in React objects and elements are recreated every render and you want to have a reference to the same thing even if it's recreated.
@Jaylaud
@Jaylaud 11 ай бұрын
My favorite tech teacher. Always on point
@prasanths8960
@prasanths8960 3 ай бұрын
Thanks for your Awesome explanation..I understood it clearly.. support from India ❤
@alekdemj
@alekdemj 9 ай бұрын
I have watched many of your videos and I want to say you are great explainer!
@vadimc4128
@vadimc4128 Жыл бұрын
Great video! The alternative way to do that is pass an object containing all the refs as a single ref. It works for me
@shinmei971
@shinmei971 2 жыл бұрын
Very clear explanation, I might use this in my projects now, it's really useful !
@zorro161
@zorro161 2 ай бұрын
bro thank you soo much you are the best the dots just connect when you were explian man thanks again man
@jellyfith
@jellyfith Жыл бұрын
Chef's kiss. Well done! Appreciate the content
@ashish_prajapati_tr
@ashish_prajapati_tr 2 жыл бұрын
your videos are very helpful. i already have found a use case of this topic by watching your tutorial. thanks.
@Dan-p7f
@Dan-p7f 2 жыл бұрын
When I learn something new I'm always checking your videos about topics that I need. Thank you so much man!
@nishaindesilva3738
@nishaindesilva3738 2 жыл бұрын
thanks! your tutorials really helps to understand about science in hooks in less cognitive overload
@ternomhwange1079
@ternomhwange1079 Жыл бұрын
Thanks for these well-explained lessons. God bless you
@daxdivv
@daxdivv 2 жыл бұрын
Next video: “Learn how to style your hair like Kyle”
@ajsyt
@ajsyt 2 жыл бұрын
ps. Using CSS
@sinc1802
@sinc1802 2 жыл бұрын
@@ajsyt I think it's something with the pseudo elements and linear gradient
@discjockeydado
@discjockeydado 2 жыл бұрын
He uses the useHairStyle hook
@adtc
@adtc Жыл бұрын
It's Brylcreem
@rayanfadhlaoui4823
@rayanfadhlaoui4823 Жыл бұрын
Thank you ! Very good/clear explanation.
@AmanSingh-px5if
@AmanSingh-px5if 2 жыл бұрын
Isn't then the usImperativeHandle just a wrapper around a useEffect which is modifying a ref? I could do the same thing by passing the ref value through the prop, and modifying it inside an useEffect in child component, any differences? or just syntactic sugar?
@sahej97
@sahej97 2 жыл бұрын
Ok, but then how would you accomplish the very last example of focusing different elements inside the child component jsx using your approach?
@SuperAsfath
@SuperAsfath 4 ай бұрын
Thanks for the amazing tutorial. I'm a non native English speaker, I watched this video with 0.75x speed. My suggestion is you may talk a bit slower, if somebody want, they can watch the video in higher speed.
@PickleRiiiiiiick
@PickleRiiiiiiick Жыл бұрын
You're killing it man. Keep going.
@samandarboymurodov8941
@samandarboymurodov8941 2 жыл бұрын
Nice tutorial, thank you for sharing this!
@akinjidesleek
@akinjidesleek Жыл бұрын
Yo I love this! Thanks Kyle.
@mhthepsycho
@mhthepsycho 5 ай бұрын
One question, you could make an object of these new references and do something like ref.current={focusButton:buttonRef.current.focus()}, what will be the problem in doing this/
@ArunKumar-bs1pg
@ArunKumar-bs1pg 8 ай бұрын
Hi. Exact same coding I tried I am able to access those functions in my parent Component. But focus is not working what might be the reason.
@damagelooper3102
@damagelooper3102 Жыл бұрын
Hi, two questions: 1) Can you only use React.forwardRef on an export default? and 2) Can you use useImperativeHandle with anything other than refs? Thank you!
@rahuls331
@rahuls331 Жыл бұрын
Answer to your first question: Not necessarily. You can use forwardRef during the component declaration too. like below const App = React.forwardRef((props, ref) => { return 'hello' }) export default App. answer to your 2nd question: React docs mentions that the hook is used to customise the ref. I'm not sure what else you could do with it. What exactly are you trying to do?
@JustSkillGG
@JustSkillGG Жыл бұрын
Very clear explanation. I have serious trouble though making useImperativeHandle to work with TypeScript
@nkululekomthimkulu1248
@nkululekomthimkulu1248 8 ай бұрын
Did you figure it out? I'll give it a try.
@igdev6095
@igdev6095 2 жыл бұрын
What is the difference between useTransition and useDefferValue hooks? I’t quite same
@mxxo4239
@mxxo4239 2 жыл бұрын
Neat. But just to make sure I'm understanding the use-case: essentially useImperativeHandle (along with useRef) allow you to call functions that live on a child component? As opposed to the old way of passing down a function as a prop where the function has to live on the parent and passed into the child?
@awekeningbro1207
@awekeningbro1207 2 жыл бұрын
yup, you can basically use this hook to expose functions that live inside child component to the parent and directly call them from there.
@tuananhdo1870
@tuananhdo1870 Жыл бұрын
Life changing video!
@free2idol1
@free2idol1 Жыл бұрын
At the end, you said that this hook should be used only in specific scenario. Can you give example of when not to use `useImperativeHandle`?
@NCS8331
@NCS8331 Жыл бұрын
Superb ❤🎉
@battle2n
@battle2n 2 жыл бұрын
9:09 woof
@bikashshrestha840
@bikashshrestha840 2 жыл бұрын
wooo. i didn't know handling model was this easy.
@lichaytiram9246
@lichaytiram9246 Жыл бұрын
It nice but i big problem is not working with input form - register isndie element block it.
@DizzyDiz2006
@DizzyDiz2006 3 ай бұрын
❤ these videos!
@jawadsrour8490
@jawadsrour8490 2 жыл бұрын
Awesome content!
@rodrigonovais9624
@rodrigonovais9624 Жыл бұрын
How can I "complement" the ref instead of override it?
@ПетърТодоров-о7ф
@ПетърТодоров-о7ф 2 жыл бұрын
Clarified it, thanks
@StilesClover
@StilesClover 2 жыл бұрын
hey it's not about the video but I would like to hear your professional opinion on this. So the thing is I'm in a little sport anime online community and well I post now since 2 years news only for the sports genre on a google sites. It works well and all but with over 170 news or better said pages it's getting kinda annoying for me and well because it's a google sites it doesn't have a lot of features but it's working. So I'm thinking now for months that I would like to switch but the question is should I use a specific website builder or do it myself? I guess the most important thing is that I really need a CMS because this would make it soooo much easier for me. I already found a site that uses CMS and it was great but the amount of CMS pages which they offered (Even with paid prices) was really limited so if I want to add more besides the news (shows, characters etc.) I would run out of space really fast :/ So any suggestions what I should do? Do it myself (but I would need a great tutorial because besides some basics I don't know much) or use a website builder (and which?).
@davlasry
@davlasry 2 жыл бұрын
I still don't understand what is wrong with doing it with props and what you mean when saying that that we will have to handle the focus state?
@Pilosofia
@Pilosofia 2 жыл бұрын
so this hook is when you want to pass a function from child to parent component. I use to do this by using context. but will be helpfull in the small and presentational components.
@stem_school
@stem_school 2 жыл бұрын
I'm interested in email validation for a new registered users, but it's not in your video list.
@pawekoaczynski4505
@pawekoaczynski4505 2 жыл бұрын
So basically, I can just grab a button with `.querySelector('.btn')`, and call the `.focus()` method, but that's not the React way to do it. So React provides use with the hook, to make the calls imperatively, kinda like in the vanilla JS. That's how I understand this
@luisbalza3774
@luisbalza3774 2 жыл бұрын
That's EXACTLY what I thought when I learned about that hook
@justin_t
@justin_t Жыл бұрын
very nice!
@Pareshbpatel
@Pareshbpatel Жыл бұрын
The useImperativeHandle hook , clearly explained. Thanks Kyle {2023-11-09}
@talkohavy
@talkohavy Жыл бұрын
Who gave you a dislike?? Stupid people on the internet... Anyway, great explanation bro! You're awesome! Love your content. Subscribed.
@umang2226
@umang2226 2 жыл бұрын
Thank you :)
@Emerald13
@Emerald13 2 жыл бұрын
Thank you!
@EnsYlmaz51
@EnsYlmaz51 5 ай бұрын
very good
@niZmosis
@niZmosis 2 жыл бұрын
That's bangin
@harshan4989
@harshan4989 2 жыл бұрын
Nice 🎉
@chrismartinez5711
@chrismartinez5711 2 жыл бұрын
Not sure why, but for the second portion I had to wrap my modal ref function within onClick. Ex {modal.current.focus1()}} >Focus On input 1 It seemed like sometimes it would work without it, sometimes not, but going this route worked all the time.
@HASHlRAMA
@HASHlRAMA 2 жыл бұрын
I still don't understand what is the purpose of the hook. Can you not just set the ref to an object containing the three functions inside a useEffect for instance?
@HASHlRAMA
@HASHlRAMA 2 жыл бұрын
@@EverRusting Sure, but that's how refs work anyways. They use the property current to actually store the value. Which is what I meant to say when I suggested to modify the ref.
@sahej97
@sahej97 2 жыл бұрын
Have you tried that in a sandbox?
@lkffkl7276
@lkffkl7276 Жыл бұрын
@@sahej97 i have, it works
@yigitruzgaruzun7289
@yigitruzgaruzun7289 2 жыл бұрын
Thanks
@zekumoru
@zekumoru Жыл бұрын
The `useImperativeHandle` hook reminds me of the `useReducer` hook in a way that rather than having a dispatch function passed down to components, we pass the actions up the component with the `useImperativeHandle` hook. Needless to say, I am not saying that `useImperativeHandle` behaves exactly the opposite of `useReducer`.
@adtc
@adtc Жыл бұрын
Yeah, with useReducer you can let children control state in the parent. With useImperativeHandle you can let the parent control some attribute of children without changing or using props.
@aarona3144
@aarona3144 2 жыл бұрын
"Was this a good video explaining useImperativeHandle?" "I can neither confirm nor deny this." Sorry, I had to. lol
@Nyco3D
@Nyco3D Жыл бұрын
Hold onto your hats, folks! 🎩😄 Get ready to transform that basic functional component into a luxurious class cruise ship! 🚀⛵ the glamorous realm of class-like functional components! 💃 But hey, you can just, use a class component! 😜
@rabahalishah5124
@rabahalishah5124 Жыл бұрын
bro why didn't use forwardref in second example?
@shawnlee6775
@shawnlee6775 2 жыл бұрын
All of that boilerplate when Svelte does that for free. Jeez.
@sahej97
@sahej97 2 жыл бұрын
I dont think it is advisable to use callbacks for the onClick event.
@mukulr5171
@mukulr5171 Жыл бұрын
🔥🔥
@medislamyah
@medislamyah 2 жыл бұрын
What i have to learn in JavaScript?
@KamalSingh-qe5oi
@KamalSingh-qe5oi Жыл бұрын
Goat
@wagiewojak
@wagiewojak 2 жыл бұрын
Coming from vue, i see that i will never start with react if i dont need to. So much bloated up
@agsrf6479
@agsrf6479 Жыл бұрын
Bumbaclot
@malikeththeblackblade2675
@malikeththeblackblade2675 Жыл бұрын
I decided to prepend if(open) to the three buttons so I wouldn't get an error if open===false
@adtc
@adtc Жыл бұрын
We can just import forwardRef directly instead of importing React.
@yeahyeahduderooski
@yeahyeahduderooski 2 жыл бұрын
Niiiice
@SohailKhan-tc8uz
@SohailKhan-tc8uz 2 жыл бұрын
Bro create a fresh React JS full course
@ShelbyLuong
@ShelbyLuong Жыл бұрын
this is like Vuejs defineExpose, right everyone ?
@ZeusTheKid
@ZeusTheKid 2 жыл бұрын
gangsta
@ricardorien
@ricardorien Жыл бұрын
You should take the oportunity and insteand throw a stupid alert, just modify the value, or reset, or put a prefix. We are tired of basic tutorials for advance features like this one.
@akshaychavan5511
@akshaychavan5511 4 ай бұрын
Succinct!
@memeyardthoughts1197
@memeyardthoughts1197 2 жыл бұрын
Here’s another useful custom hook you can create in react to detect user activity. It’s called useActive hook. Check it out - kzbin.info/www/bejne/n5PGdIyCa7CZZ5Y
@blueblue9410
@blueblue9410 2 жыл бұрын
what the fuck is going on
@devfreemax3578
@devfreemax3578 2 жыл бұрын
Kyle you're crack
@dpaulflavius
@dpaulflavius 2 жыл бұрын
learn how to use it and forgot right away 😁
@anasouardini
@anasouardini Жыл бұрын
So, all of this so that you don't use an object inside of a Ref? After reading the docs, asking people on Discord and watching a video on KZbin, I still think it's an entirely useless hook. I just don't know why React team just like to confuse people!!
@alii4334
@alii4334 2 жыл бұрын
Awesome content!
@doniaelfouly4142
@doniaelfouly4142 Жыл бұрын
thanks
The Perfect Hook For Debugging Custom React Hooks
8:07
Web Dev Simplified
Рет қаралды 34 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 493 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Learn useMemo In 10 Minutes
10:42
Web Dev Simplified
Рет қаралды 494 М.
Learn React Hooks: useImperativeHandle - Simply Explained!
9:54
Cosden Solutions
Рет қаралды 25 М.
A Trick Every React Developer Should Know: Ref Forwarding
9:08
Josh tried coding
Рет қаралды 21 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 396 М.
Never Forget React forwardRef Again
9:33
Coding in Public
Рет қаралды 23 М.
Most Beginner React Developers Do This Wrong
13:47
Web Dev Simplified
Рет қаралды 238 М.
The CSS Display Property is Changing Forever
15:20
Web Dev Simplified
Рет қаралды 77 М.
How To Build Feature Flags Like A Senior Dev In 20 Minutes
20:33
Web Dev Simplified
Рет қаралды 109 М.
Learn useReducer In 20 Minutes
20:12
Web Dev Simplified
Рет қаралды 521 М.
Top 6 React Hook Mistakes Beginners Make
21:18
Web Dev Simplified
Рет қаралды 584 М.