Full React Tutorial #20 - Making a Custom Hook

  Рет қаралды 272,906

Net Ninja

Net Ninja

Күн бұрын

Пікірлер: 354
@markg5986
@markg5986 3 жыл бұрын
I love the humility of comments like "Fingers-crossed, this should all work..."
@simpletechtips8442
@simpletechtips8442 3 жыл бұрын
Thank you for this. This whole series has explained Hooks and Props in an outstanding way.
@NetNinja
@NetNinja 3 жыл бұрын
Glad you enjoyed it! 😃
@mjylove2
@mjylove2 6 ай бұрын
same here, this video is where i finally understood the custom hook concept
@BigTime929
@BigTime929 3 жыл бұрын
i love the way you explain things, such as 4:30 "this data will not clash with the useState data because it's the local version inside this function" cause it may confuses some people but u made it clear for all of your viewers!
@ericmomoh7927
@ericmomoh7927 2 жыл бұрын
I have struggled with reacts for months until I bumped into this channel. Understanding is here.
@geojolly7512
@geojolly7512 3 жыл бұрын
I really like this man. I want a teacher like him.
@mircast0
@mircast0 3 жыл бұрын
You do have one. On this channel. And that's awesome! :)
@peterbrink4421
@peterbrink4421 2 жыл бұрын
I am about half way through this series and I just want to say thank you for the incredible content. Congratulations, not many have the ability to explain things in such a concise yet interesting way.
@mysticguava
@mysticguava 3 жыл бұрын
You explained everything in a clean and simple way that no one else did. Thanks, Shaun
@NetNinja
@NetNinja 3 жыл бұрын
Thank you! 😃
@CrazyClips108
@CrazyClips108 3 жыл бұрын
NetNinja's courses are based on the principle 'do it wrongly to understand it and to never forget'. Brilliant !
@SkyrimBeast
@SkyrimBeast 2 жыл бұрын
I'm working on an app that pulls movies from different genre's via TMDB. It quickly became clear to me that my code was getting beyond repetitive and hard to manage. A custom hook is exactly what I needed. Huge thanks for this Net Ninja. Whenever I do get a job as a React developer, I'll owe a large part of that success to you. Much ❤
@SamChaneyProductions
@SamChaneyProductions Жыл бұрын
At 4:15 you can just press F2 to rename a variable in VSCode. This will ensure you don't miss any of them and it's much faster
@mr.rambaviskar
@mr.rambaviskar Жыл бұрын
Thanks sam❤
@Fred_Klingon
@Fred_Klingon 26 күн бұрын
I'm following the whole course since the first lesson, I really like your explanations, not too fast but straight to the point. Also this episode is really gold! I always avoided React in these years, but in this lesson I can see that if used properly, it makes code reuse and readability very easy!
@louis_dev6981
@louis_dev6981 3 жыл бұрын
Thank you so much for making this video series. You explain the fundamental concepts of React such as hooks, state and props in a clear and easy-to-understand manner, so it really helps me to learn React and get comfortable with using React in my project 🙏🏼
@unknownman1
@unknownman1 3 жыл бұрын
I'm following the series regularly, waiting for the next tutorial. Thanks Shaun you are great
@Onyecode
@Onyecode Жыл бұрын
Just started this course and I have already built a landing page, something I have been tryjng for a year now, thanks so much
@NetNinja
@NetNinja Жыл бұрын
Happy to help!
@kevinnzeng7081
@kevinnzeng7081 3 жыл бұрын
You are great Shaun ! Your courses are so fluid, clear that everything look so easy with you. Thanks a lot
@MrRobeezy29
@MrRobeezy29 3 жыл бұрын
So good. Other tutorials on youtube made it way more complicated than it had to be...thank you so much for clearing this up!
@alexgrinberg1888
@alexgrinberg1888 3 жыл бұрын
Your courses are clear and concise. Right to the point. Really easy to learn. Especially for the professionals who do not have much time and need to learn React in several days. Huge Thanks!!! Please keep up creating such great content!
@nroshstp
@nroshstp 3 жыл бұрын
best practice for coding full-on mate, loving the way you simplifying things. Thank you very much !!
@NetNinja
@NetNinja 3 жыл бұрын
Thank you 😃
@maskman4821
@maskman4821 3 жыл бұрын
React Custom hook is pretty much like Vue Composable, actually they are the same thing, I have just finished Shaun's vue3 course on udemy and this react series helps a lot to understand and compare these two frameworks, thank you Shaun for this terrific chapter !!!
@NetNinja
@NetNinja 3 жыл бұрын
Yeah - they are very similar.
@PavanKumar-tt6tw
@PavanKumar-tt6tw 2 жыл бұрын
Hey Shaun, you are one of the finest teachers, I've ever encountered. Thanks a lot for offering this amazing content. Your way of explaining things is just awesome. Straight to the point. Loads of love from India. Universe bless you with prosperty, love, health and wealth.
@NetNinja
@NetNinja 2 жыл бұрын
Thank you so much for your support Pavan :)
@sueholder703
@sueholder703 3 жыл бұрын
I wish I'd had Shaun as my personal tutor all the way through school. I'd have learned so much more! He breaks it down so you can easily understand each piece so that when he moves on to the next piece, you understand what is going on! I am going to hit JOIN so that he can be my teacher!
@sueholder703
@sueholder703 3 жыл бұрын
I don't see JOIN, I see SEE PERKS!
@NetNinja
@NetNinja 3 жыл бұрын
Thanks so much :)
@tehtriangle6660
@tehtriangle6660 3 жыл бұрын
This is an incredibly easy-to-follow tutorial on custom hooks. Thanks!
@philjacks8531
@philjacks8531 3 жыл бұрын
This is an amazing React course. This lesson is awesome, I can see myself reusing this in many projects. Thanks for all your content.
@johnconnor9787
@johnconnor9787 3 жыл бұрын
The best explanation of custom hook implementation on KZbin
@matheusschlosserbasso5649
@matheusschlosserbasso5649 3 жыл бұрын
Thank you SO much! This is the best content I've seen so far... I've learned more in this course than in months of other courses.
@ruziatepvp
@ruziatepvp 2 жыл бұрын
I mean, i tried to make tutorials like this 15 years ago (Joomla stuff) - and let me say this: it is very, very - veeeeeery hard. I for myself had to stop every 15 seconds or so, because i messed up and in the end, you find something thats incorrect or not working out as you wished for, so you have to start over from the scratch. So damn respect for those clips Mr. Net Ninja, hands down!
@nielfollero5
@nielfollero5 3 жыл бұрын
6:18 Do we really need to add the url in the dependencies of useEffect? Cause I think the url is not gonna be changed during the run time of that custom hook, thus putting url will be useless, just putting [ ] is enough to prevent the infinite execution of useEffect whenever the useState data change. I might be wrong. I'm just basing all of that from what I've learned during this series only, I'm only a student lol.
@rpanda_old
@rpanda_old 3 жыл бұрын
i have the same doubt. I didnt understand why URL is added as a dependency to the hook
@Alphashow7
@Alphashow7 3 жыл бұрын
Same thoughts, considering that url is not even a state, can the useEffect even react to a variable that isn't a state ?
@vladyslavstadnyk2762
@vladyslavstadnyk2762 10 ай бұрын
Following the logic of states, probably to prevent doing not necessry backend calls on any possible re-renders of other components non related to the url.
@sumisastri5681
@sumisastri5681 2 жыл бұрын
This is one of the most useful modules in the course a great way to abstract out an API call and reuse it with a custom hook. Thanks @Shaun
@akinrotimidaniel2325
@akinrotimidaniel2325 Жыл бұрын
Kudos bro, I'm no fan of JavaScript, or should I say 'was'. This tutorial is just perfect
@levaniakobidze8202
@levaniakobidze8202 2 жыл бұрын
That's the best explenation of custom hooks. Thanks a lot.
@NetNinja
@NetNinja 2 жыл бұрын
You're welcome! hope it was helpful :)
@darumaleo
@darumaleo 8 ай бұрын
that was really smooth and satisfying to watch
@priyankkharat7407
@priyankkharat7407 3 жыл бұрын
Really love the series
@kristofferjohansson3768
@kristofferjohansson3768 3 жыл бұрын
I just love when all pieces are put in place. Beautiful!
@sushilbalami
@sushilbalami 3 жыл бұрын
That's what I am waiting for, ❤ Please make it a complete course so that by looking on to documentation we can understand what does it mean, ❤
@MrGlujaN
@MrGlujaN 3 жыл бұрын
Dude, thank you so much, your videos on react made me get my first job on tech
@learningit2572
@learningit2572 2 жыл бұрын
OMG YOU ARE NUMBER ONE NINJA IN THE WEB. Ukraine watching)) thanks so much.
@devapps-uk
@devapps-uk 3 жыл бұрын
gonna refactor my personal project with custom hook like your way, thanks :)
@napsarenice
@napsarenice 2 жыл бұрын
Excellent, clear explanation. This was super helpful in understanding how to create custom hooks. Thank you!
@spondoolie6450
@spondoolie6450 2 жыл бұрын
Everything that was confusing to me about making custom hooks was explained in less than 9 minutes. I feel like this is my weakest part of React at this moment.... so this video is definitely getting saved in my "React" playlist.
@aarensan
@aarensan 3 жыл бұрын
Best I've seen so far! Very comprehensible.
@Yahya-u5x
@Yahya-u5x Жыл бұрын
This is the what i was looking for, you saved my life i was struggling to move the useEffect to another file. Thank you ❤
@NetNinja
@NetNinja Жыл бұрын
Glad to hear that! :) thanks
@muhammadjonnazarov146
@muhammadjonnazarov146 7 ай бұрын
Wonderful and easy way to understand the concept. Thanks a lot. Please, keep creating such wonderful tutorials.
@NetNinja
@NetNinja 7 ай бұрын
Thank you muhammad :) much appreciated!
@mjylove2
@mjylove2 6 ай бұрын
your React Tutorial series is legendary. huge thanks to you !
@NetNinja
@NetNinja 6 ай бұрын
I appreciate that! :) thanks so much for watching
@markyanthonylaredo2614
@markyanthonylaredo2614 3 жыл бұрын
I love this ninja way of toturial 😍❤
@franjosipovic5766
@franjosipovic5766 3 жыл бұрын
Broo you are amazing. I love programming 10 times more because of you!!! Will you do in the future series where you connect backend and frontend...for example django + react or something similar?
@NetNinja
@NetNinja 3 жыл бұрын
Yeah I will be doing a more full-stack project in the future :)
@bofinannhor3566
@bofinannhor3566 3 жыл бұрын
you are the first teacher that made me understand the react
@RizkyGusna
@RizkyGusna 3 жыл бұрын
This tutorial has been a blast so far! Great explanation!
@Kilopillz
@Kilopillz 2 жыл бұрын
Thank you for this. This is the exact problem I was trying to solve. Starting this course from the beginning.
@ashwinsuryawanshi
@ashwinsuryawanshi Жыл бұрын
Thanks for giving a super practical use case for the example. This makes code very clean and easy to use. ⭐
@mpho438
@mpho438 2 жыл бұрын
I'm starting to enjoy react, everything is clear and concise and pretty much easy to follow, I'm about to finish this series but I constantly going to come back from time to time for revision.
@ayinlaoluwafemi1993
@ayinlaoluwafemi1993 3 жыл бұрын
Thank you Net Ninja for making what seems difficult to understand easy.
@Shahzaib_Atif
@Shahzaib_Atif Жыл бұрын
That's excellent explanation. The only thing I would like to add in this custom hook is a cleanup function to abort the fetch request in case of unmounting etc.
@CptBouchard
@CptBouchard 3 жыл бұрын
So much clear in my mind now, with such good explanations! THANK YOU!
@royataleghani6519
@royataleghani6519 2 жыл бұрын
Great tutorial, very clear and easy to understand the logic. Thank you so much.
@NetNinja
@NetNinja 2 жыл бұрын
You're very welcome! Thanks for watching Roya
@urbainquentin1663
@urbainquentin1663 2 жыл бұрын
Best react course ever
@NetNinja
@NetNinja 2 жыл бұрын
Thanks Urbain
@lukasluftlaufer1093
@lukasluftlaufer1093 2 жыл бұрын
Exactly what I needed! Thanks Shaun! 🧡
@michaelzucker772
@michaelzucker772 3 жыл бұрын
Thank you for your videos. I love the way you explain the concepts along the way.
@keishawaithe-johnson5034
@keishawaithe-johnson5034 3 жыл бұрын
Exactly what I've been looking for! Explained so simply 👌
@rohan1765
@rohan1765 3 жыл бұрын
Fabulous explaination 👍🏼
@HostDotPromo
@HostDotPromo 3 жыл бұрын
Agreed, very easy to understand.
@m_imran_khan
@m_imran_khan 2 жыл бұрын
Excellent resource. Thanks for you effort mate, appreciate it.
@MiikaKontio
@MiikaKontio Жыл бұрын
Really good tutorial and helped me exactly how I needed. I managed to do useFetch myself and get rid of hundreds of lines of duplicate code
@lokmanhossainpappu5096
@lokmanhossainpappu5096 3 жыл бұрын
Love you shaun. And love your awesome content. Your content better than paid course. keep going
@hseinb
@hseinb 3 жыл бұрын
thanks shaun, you're a gifted teacher
@krish4659
@krish4659 11 ай бұрын
Just a note from my observation : the names of returned properties from useFetch() and the names mentioned in destructing properties in home.js if return {data} is mentioned in useFetch , in homejs also it should be {data : alias}= useFetch("url");
@trangnusi13
@trangnusi13 3 жыл бұрын
Thank you. I really like your tutorials. Well done!
@mohamedamin-g3f7n
@mohamedamin-g3f7n Жыл бұрын
i love you man, your tutorials are simply amazing
@NetNinja
@NetNinja Жыл бұрын
Thanks Mohamed, that means a lot :)
@VS257
@VS257 3 жыл бұрын
I have a question. When you have a custom hook and all the states are transferred from Home component to the custom hook, is it still the Home component's states? OR does it become sort of a global state in whichever component that custom hook is used?
@rpanda_old
@rpanda_old 3 жыл бұрын
i have the same doubt
@keifonlee8342
@keifonlee8342 3 жыл бұрын
same doubt and don't cant find the answer
@miladnouri4364
@miladnouri4364 3 жыл бұрын
I think the custom hook is specific to whatever component is using it, changing the state data in one component will not cause to change data in another component, even if they are both using the same custom hook. To share state data across multiple components in a large project, you should use Redux or React Context.
@FahadKhan-rp3rz
@FahadKhan-rp3rz 3 жыл бұрын
This is the clear definition that how react context works.
@ibadshaikh2215
@ibadshaikh2215 3 жыл бұрын
Extraordinary explanation dude!
@frazbakht4480
@frazbakht4480 3 жыл бұрын
I am learning so much. Really thank you for this!
@deepakkvijayan
@deepakkvijayan 2 жыл бұрын
Hey Shaun. You are one of the best teachers on youtube. I find your videos clear and to the point. Hands down the best. I have a query. Hooks can't be used inside other hooks right. So how come useState is working inside the custom hook "useFetch". For me it's giving an error. I watched this video many times. I don’t think I am doing anything different .
@Anteater23
@Anteater23 6 ай бұрын
You are the best. Some other channels go at 100mph and I learn nothing.
@waltergermanes4528
@waltergermanes4528 2 жыл бұрын
Very straightforward explaination, thank you very much 😃
3 жыл бұрын
Great way to explain this. Thanks a lot! Greetings from Colombia.
@ghofranedarragi5601
@ghofranedarragi5601 3 жыл бұрын
really thank you for your detailed and clear explanation ❤❤
@bassamsaleh5396
@bassamsaleh5396 Жыл бұрын
updating on a bit of an experiment for me. you do not have to name ur custom hooks with "use" at the start of them as they seem to me like regular javascript functions, so even if you name them something else like "FetchItUp69" they will still work, however it is probably a good idea to keep using the "use" before ur hook name to stay consistent. also for whoever cares, the hook will behave like a "class instance" (if ur coming from an OOP POV) for the component it was called on, i share this with u cuz these questions popped in my mind and i started experimenting to find the answers. *I hope im not wrong*
@MultiTrickster121
@MultiTrickster121 3 жыл бұрын
Why do we need to add the url as a dependency in useEffect? I thought the useEffect hook would only run if it was called inside a component anyway, so why do we need to specify that it needs to run when the url changes?
@woofcode3383
@woofcode3383 3 жыл бұрын
As always, superb nugget! Thank You!
@asifurrahman8257
@asifurrahman8257 3 жыл бұрын
man you explain like butter
@emmanuelngwenya9845
@emmanuelngwenya9845 3 жыл бұрын
Youre the best man....like you are a very good explainer
@CreativeTutorialsWeb
@CreativeTutorialsWeb 3 жыл бұрын
Love your courses bro keep rising full support from me
@chasec4897
@chasec4897 2 жыл бұрын
You are a gift from the gods.
@lucasfernandes9381
@lucasfernandes9381 3 жыл бұрын
Although I found it complicated at first, I loved it.
@corsaronero5619
@corsaronero5619 3 жыл бұрын
Hi Shaun, thanks for your beautiful video tutorial, can you explain the component communication between sibling. all videos are about parent child, but what about if I have an App.js with 3 components, left, top, bottom and anytime I click on the left component I want to see the detail on the top component and all 3 components are visible on the same page? thanks
@megaguys-b8k
@megaguys-b8k 4 ай бұрын
Everithing is very clear, thank you sensei❤
@NetNinja
@NetNinja 4 ай бұрын
Awesome, thanks for watching!
@sohaibkhan845
@sohaibkhan845 2 жыл бұрын
Best tutorial series for react
@mew6085
@mew6085 2 жыл бұрын
Your course is very well! Thanks a lot)
@mhassankhan8677
@mhassankhan8677 2 жыл бұрын
straight to the point. awesome!
@lucasmaus9597
@lucasmaus9597 2 жыл бұрын
Just on point. Awesome tutorial!
@xxxxxzzee23
@xxxxxzzee23 2 жыл бұрын
This is exactly the best tut!!!!!!!!!!! 💗
@AbhishekVaid
@AbhishekVaid 7 ай бұрын
at 6:21, the fact that url is passed into dependency array doesn't make sense since it's just variable and not a useEffect type entity
@mariampureliani7215
@mariampureliani7215 Жыл бұрын
Love the way you explain every detail! 💫 You da Best 💯❤
@MuhammadSaaddev
@MuhammadSaaddev 2 жыл бұрын
You Sir, are a LEGEND !
@abtaf7449
@abtaf7449 Жыл бұрын
it is one of the best learning methods that suit me! thanks👋
@NetNinja
@NetNinja Жыл бұрын
Glad to hear that! thanks Abtaf
@cartman42069
@cartman42069 3 жыл бұрын
wow. so well explained. thanks a lot!!!
@GintasLtu
@GintasLtu Жыл бұрын
At lesson 20 have issues with "Unexpected token '
@vladyslavstadnyk2762
@vladyslavstadnyk2762 10 ай бұрын
Because you've got not valid json response. It's related to the CORS, I suppose, struggling with the same error.
@ZTF666
@ZTF666 3 жыл бұрын
Beautiful and easy so far !
@Vincent1990-l1y
@Vincent1990-l1y 3 жыл бұрын
God damn it, I really enjoy of watching these tutorials! Damn you're good
@TheNamesJT
@TheNamesJT 3 жыл бұрын
I'm confused with the object de-structuring cause it looks similar to setting a value for an object key example {id: 1} here we set 1 to be the value of id but when you use {data: blogs} this is just renaming it and doesn't change its value and what it returns. How can you tell the difference?
@farhanaditya2647
@farhanaditya2647 3 жыл бұрын
When you're setting a value, you're assigning the object to a variable. But when you destructure an object, you grab the values from a variable. // assignment let variable = { key: value } // destructure let { key: value } = variable
@cryptopinky2355
@cryptopinky2355 Жыл бұрын
this is awesome! the best explanation of the topics/
@terjemah_alquran
@terjemah_alquran 3 жыл бұрын
thank you, very clear. start to refactor my codes
Full React Tutorial #21 - The React Router
8:22
Net Ninja
Рет қаралды 530 М.
Custom Hooks in React (Design Patterns)
12:56
Cosden Solutions
Рет қаралды 55 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Full React Tutorial #16 - Using JSON Server
5:11
Net Ninja
Рет қаралды 356 М.
Learn Custom Hooks In 10 Minutes
9:38
Web Dev Simplified
Рет қаралды 258 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 853 М.
10 React Hooks Explained // Plus Build your own from Scratch
13:15
Fireship
Рет қаралды 1,4 МЛН
Full React Tutorial #19 - Handling Fetch Errors
7:39
Net Ninja
Рет қаралды 254 М.
Turning bad React code into senior React code
13:10
Cosden Solutions
Рет қаралды 94 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 176 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН