Тёмный

Full React Tutorial #20 - Making a Custom Hook 

Net Ninja
Подписаться 1,6 млн
Просмотров 265 тыс.
50% 1

🐱‍💻 🐱‍💻 Course Files:
+ github.com/iam...
🐱‍👤🐱‍👤 JOIN THE GANG -
/ @netninja
🐱‍💻 🐱‍💻 My Udemy Courses:
+ Modern JavaScript - www.thenetninj...
+ Vue JS & Firebase - www.thenetninj...
+ D3.js & Firebase - www.thenetninj...
🐱‍💻 🐱‍💻 Helpful Links:
+ HTML & CSS Course - • HTML & CSS Crash Cours...
+ Modern JavaScript course - • Modern JavaScript Tuto...
+ Get VS Code - code.visualstu...
🐱‍💻 🐱‍💻 Social Links:
Facebook - / thenetninjauk
Twitter - / thenetninjauk
Instagram - / thenetninja

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

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 349   
@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 4 месяца назад
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.
@mysticguava
@mysticguava 3 года назад
You explained everything in a clean and simple way that no one else did. Thanks, Shaun
@NetNinja
@NetNinja 3 года назад
Thank you! 😃
@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.
@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 ❤
@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
@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 :)
@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 😃
@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!
@tehtriangle6660
@tehtriangle6660 3 года назад
This is an incredibly easy-to-follow tutorial on custom hooks. Thanks!
@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!
@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.
@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 :)
@Onyecode
@Onyecode 11 месяцев назад
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 11 месяцев назад
Happy to help!
@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, ❤
@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.
@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 :)
@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! :)
@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
@mjylove2
@mjylove2 3 месяца назад
your React Tutorial series is legendary. huge thanks to you !
@NetNinja
@NetNinja 3 месяца назад
I appreciate that! :) thanks so much for watching
@levaniakobidze8202
@levaniakobidze8202 2 года назад
That's the best explenation of custom hooks. Thanks a lot.
@NetNinja
@NetNinja 2 года назад
You're welcome! hope it was helpful :)
@johnconnor9787
@johnconnor9787 3 года назад
The best explanation of custom hook implementation on RU-vid
@muhammadjonnazarov146
@muhammadjonnazarov146 4 месяца назад
Wonderful and easy way to understand the concept. Thanks a lot. Please, keep creating such wonderful tutorials.
@NetNinja
@NetNinja 4 месяца назад
Thank you muhammad :) much appreciated!
@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 .
@priyankkharat7407
@priyankkharat7407 3 года назад
Really love the series
@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!
@markyanthonylaredo2614
@markyanthonylaredo2614 3 года назад
I love this ninja way of toturial 😍❤
@akinrotimidaniel2325
@akinrotimidaniel2325 Год назад
Kudos bro, I'm no fan of JavaScript, or should I say 'was'. This tutorial is just perfect
@teejaayme
@teejaayme 3 года назад
gonna refactor my personal project with custom hook like your way, thanks :)
@Yahya-u5x
@Yahya-u5x 10 месяцев назад
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 10 месяцев назад
Glad to hear that! :) thanks
@kristofferjohansson3768
@kristofferjohansson3768 3 года назад
I just love when all pieces are put in place. Beautiful!
@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❤
@napsarenice
@napsarenice 2 года назад
Excellent, clear explanation. This was super helpful in understanding how to create custom hooks. Thank you!
@MrGlujaN
@MrGlujaN 2 года назад
Dude, thank you so much, your videos on react made me get my first job on tech
@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.
@ashwinsuryawanshi
@ashwinsuryawanshi Год назад
Thanks for giving a super practical use case for the example. This makes code very clean and easy to use. ⭐
@ayinlaoluwafemi1993
@ayinlaoluwafemi1993 3 года назад
Thank you Net Ninja for making what seems difficult to understand easy.
@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?
@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.
@Kilopillz
@Kilopillz 2 года назад
Thank you for this. This is the exact problem I was trying to solve. Starting this course from the beginning.
@CptBouchard
@CptBouchard 2 года назад
So much clear in my mind now, with such good explanations! THANK YOU!
@rohan1765
@rohan1765 3 года назад
Fabulous explaination 👍🏼
@HostDotPromo
@HostDotPromo 3 года назад
Agreed, very easy to understand.
@keishawaithe-johnson5034
@keishawaithe-johnson5034 3 года назад
Exactly what I've been looking for! Explained so simply 👌
@RizkyGusna
@RizkyGusna 2 года назад
This tutorial has been a blast so far! Great explanation!
@royataleghani6519
@royataleghani6519 Год назад
Great tutorial, very clear and easy to understand the logic. Thank you so much.
@NetNinja
@NetNinja Год назад
You're very welcome! Thanks for watching Roya
@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 8 месяцев назад
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.
@michaelzucker772
@michaelzucker772 3 года назад
Thank you for your videos. I love the way you explain the concepts along the way.
@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
@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.
@waltergermanes4528
@waltergermanes4528 Год назад
Very straightforward explaination, thank you very much 😃
@megaguys-b8k
@megaguys-b8k Месяц назад
Everithing is very clear, thank you sensei❤
@NetNinja
@NetNinja Месяц назад
Awesome, thanks for watching!
@spondoolie6450
@spondoolie6450 Год назад
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.
@learningit2572
@learningit2572 2 года назад
OMG YOU ARE NUMBER ONE NINJA IN THE WEB. Ukraine watching)) thanks so much.
@Anteater23
@Anteater23 3 месяца назад
You are the best. Some other channels go at 100mph and I learn nothing.
@asifurrahman8257
@asifurrahman8257 3 года назад
man you explain like butter
@mohamedamin-g3f7n
@mohamedamin-g3f7n Год назад
i love you man, your tutorials are simply amazing
@NetNinja
@NetNinja Год назад
Thanks Mohamed, that means a lot :)
@m_imran_khan
@m_imran_khan 2 года назад
Excellent resource. Thanks for you effort mate, appreciate it.
@sohaibkhan845
@sohaibkhan845 2 года назад
Best tutorial series for react
@frazbakht4480
@frazbakht4480 3 года назад
I am learning so much. Really thank you for this!
@krish4659
@krish4659 8 месяцев назад
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");
3 года назад
Great way to explain this. Thanks a lot! Greetings from Colombia.
@emmanuelngwenya9845
@emmanuelngwenya9845 2 года назад
Youre the best man....like you are a very good explainer
@ghofranedarragi5601
@ghofranedarragi5601 3 года назад
really thank you for your detailed and clear explanation ❤❤
@FahadKhan-rp3rz
@FahadKhan-rp3rz 3 года назад
This is the clear definition that how react context works.
@trangnusi13
@trangnusi13 3 года назад
Thank you. I really like your tutorials. Well done!
@mew6085
@mew6085 2 года назад
Your course is very well! Thanks a lot)
@chasec4897
@chasec4897 2 года назад
You are a gift from the gods.
@bassamsaleh5396
@bassamsaleh5396 10 месяцев назад
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*
@hseinb
@hseinb 3 года назад
thanks shaun, you're a gifted teacher
@abtaf7449
@abtaf7449 Год назад
it is one of the best learning methods that suit me! thanks👋
@NetNinja
@NetNinja Год назад
Glad to hear that! thanks Abtaf
@woofcode3383
@woofcode3383 3 года назад
As always, superb nugget! Thank You!
@urbainquentin1663
@urbainquentin1663 2 года назад
Best react course ever
@NetNinja
@NetNinja 2 года назад
Thanks Urbain
@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
@abhishekbharti704
@abhishekbharti704 Месяц назад
Amazing explanation!
@ibadshaikh2215
@ibadshaikh2215 3 года назад
Extraordinary explanation dude!
@mhassankhan8677
@mhassankhan8677 Год назад
straight to the point. awesome!
@bryanmora4996
@bryanmora4996 2 года назад
ok so, the thing is that i read somewhere that making an explicit request in the page component is considered a bad practice, so I've been trying to use this hook in order to just run an action in the page component, then tree shake the data from the context but I can't use this hook in my context bc the actions that my context runs do not return jsx data, so the useState and useEffect of the hook are invalid inside those functions, what should I do?
@nakedsnake_2128
@nakedsnake_2128 Год назад
For the first time I don't want a tutorial to end - learning so freaking much
@terjemah_alquran
@terjemah_alquran 3 года назад
thank you, very clear. start to refactor my codes
@xxxxxzzee23
@xxxxxzzee23 2 года назад
This is exactly the best tut!!!!!!!!!!! 💗
@lucasfernandes9381
@lucasfernandes9381 3 года назад
Although I found it complicated at first, I loved it.
@pioppappaiatv5448
@pioppappaiatv5448 2 года назад
excellent explanation, thank you
@ZTF666
@ZTF666 3 года назад
Beautiful and easy so far !
@cryptopinky2355
@cryptopinky2355 Год назад
this is awesome! the best explanation of the topics/
@braddey8918
@braddey8918 3 года назад
And I'm sure no one can teach me chart js with react except Mr ninja master
@hankoiba9032
@hankoiba9032 3 года назад
just use the const myRef = useRef() before the useEffect and make a return jsx with a , then make a const Mycontext = myRef.current.getContext('2d') inside the useEffect hook , create a new instance of Chart and pass the logic you want and boom you have it
@maskman4821
@maskman4821 3 года назад
@@hankoiba9032 pretty cool !!!
@lucasmaus9597
@lucasmaus9597 2 года назад
Just on point. Awesome tutorial!
@danialranjbar9805
@danialranjbar9805 2 года назад
Happy with ur tutorials
@johnconnor9787
@johnconnor9787 3 года назад
You are a real Net Ninja
@cartman42069
@cartman42069 2 года назад
wow. so well explained. thanks a lot!!!
@CodeRCreatives
@CodeRCreatives 3 года назад
Thank you a lot for your contribution as an awesome teacher....you are awesome.
@andromilk2634
@andromilk2634 6 месяцев назад
Hi, the only thing which I'm not sure of is in regards of putting the URL in the dependency array : I was under the impression that the initial reason we left this empty was based on the idea that we would only need to import the data on the initial render of the component. Why did this change now? By putting the URL in the array, wouldn't this mean we can now import several times data in the same component and not only at its mount? Thanks
@MuhammadSaaddev
@MuhammadSaaddev Год назад
You Sir, are a LEGEND !
@drhastings
@drhastings 3 года назад
Thank you Shaun🙌🏾
@minjunguitar
@minjunguitar 3 года назад
Thanks for the awesome course! Can the value inside the second parameter of useEffect be anything (function, state, variable)? I thought for some reason it has to be a state.
@hank91918
@hank91918 3 года назад
so elegant, love it!
@kmcg101
@kmcg101 6 месяцев назад
thanks for the tutorial. Why do you use useEffect inside of the custom hook and not just organize the custom hook as a function that returns your 3 values?
@acidhauss7018
@acidhauss7018 2 года назад
best hooks tutorial thanks
Далее
Full React Tutorial #21 - The React Router
8:22
Просмотров 512 тыс.
React Hooks Course - All React Hooks Explained
1:26:21
Просмотров 1,1 млн
Full React Tutorial #19 - Handling Fetch Errors
7:39
Просмотров 248 тыс.
Learn Custom Hooks In 10 Minutes
9:38
Просмотров 253 тыс.
Full React Tutorial #16 - Using JSON Server
5:11
Просмотров 346 тыс.
Learn useReducer In 20 Minutes
20:12
Просмотров 507 тыс.
10 React Antipatterns to Avoid - Code This, Not That!
8:55
Full React Tutorial #17 - Fetching Data with useEffect
7:55