Тёмный

Full React Tutorial #15 - useEffect Dependencies 

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

Hey gang, in this React tutorial we'll talk about how we can control when the useEffect function fires - by using a dependency array.
🐱‍💻 🐱‍💻 Course Files:
+ github.com/iamshaunjp/Complet...
🐱‍👤🐱‍👤 JOIN THE GANG -
/ @netninja
🐱‍💻 🐱‍💻 My Udemy Courses:
+ Modern JavaScript - www.thenetninja.co.uk/udemy/m...
+ Vue JS & Firebase - www.thenetninja.co.uk/udemy/v...
+ D3.js & Firebase - www.thenetninja.co.uk/udemy/d...
🐱‍💻 🐱‍💻 Helpful Links:
+ HTML & CSS Course - • HTML & CSS Crash Cours...
+ Modern JavaScript course - • Modern JavaScript Tuto...
+ Get VS Code - code.visualstudio.com/
🐱‍💻 🐱‍💻 Social Links:
Facebook - / thenetninjauk
Twitter - / thenetninjauk
Instagram - / thenetninja

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

 

6 янв 2021

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 132   
@uzair004
@uzair004 2 года назад
For new viewers: your component might update twice on first run while mounting, it is because newer version of React has StrictMode which ran it twice on development environment for debugging purpose, it will be once in case of production
@rohitgokarn7952
@rohitgokarn7952 2 года назад
Thanks. I was wondering why its happening
@susmantobealivebruh4238
@susmantobealivebruh4238 Год назад
BRO THIS JUST FIXED MY ERRORIN MY FINAL YEAR PROJECT THANK YOU VERY MUCHHHHH
@pamp3657
@pamp3657 Год назад
thank you
@rakeshwasnik9327
@rakeshwasnik9327 Год назад
thanks
@williambradley1448
@williambradley1448 Год назад
Thank you so much, this was driving me nuts!
@basselturky4027
@basselturky4027 2 года назад
Wow, is this heaven?! I been watching hour-long videos and no one managed to explain useEffect at all and you did it in two videos 4min each. Big big thanks man I'm so grateful, I can't put it in words.
@Toulkun
@Toulkun 11 месяцев назад
True, even documentations are very complex and dont explain very well in depth, they fail to.
@johongirrahimov2343
@johongirrahimov2343 2 года назад
***SUMMARY*** useEffect() -- accepts the second argument which is an empty array and is called dependency. When you leave dependency array empty, the callback in useEffect is invoked only once when component renders to the DOM but never again invoked even if component re-renders. Proviging state data - When you provide state value/data as dependency to the dependency array, callback fires each time that value changes
@demehinibukun1445
@demehinibukun1445 3 года назад
Such a simple explanation.... Weldone brother
@hassanhafiz44
@hassanhafiz44 3 года назад
Hi Sir! I just watched, NodeJS, JWT Auth, Tailwind CSS and This React Series in just two days. Thanks for the efforts.
@joke4ey431
@joke4ey431 2 года назад
Literally, I'm watching this course like a serial, having so much fun and waiting for the next episode :D. Shaun is a master, hats off.
@awhitechilliify
@awhitechilliify 3 года назад
Thank you for sharing your knowledge, Shaun! A real-life website example where the dependency are used successfully would be amazing!
@StevieB86
@StevieB86 6 месяцев назад
Why can't every RU-vidr in this niche explain things this clearly. Brilliant video~!
@maskman4821
@maskman4821 3 года назад
Thank yoy Shawn for explaining useeffect dependencies with terrific example, now I understand much more about useeffect !!!
@toddcamnitz6164
@toddcamnitz6164 Год назад
Your explanations are mind-blowingly helpful and concise. I come to these videos after days of lecture in my coding bootcamp to understand the things we talked about in class, and you manage to clear up *so much.*
@Asimz
@Asimz 3 года назад
Simple yet effective explanations as always mate! Love the content
@kotaproluhemanth2585
@kotaproluhemanth2585 2 года назад
This playlist is diamond!!!Understood every concept clearly...
@sazidahmed3012
@sazidahmed3012 3 года назад
Thank you. You're the best frontend instructor.
@billpapas3054
@billpapas3054 3 года назад
Bro what i can say for ur epic simple smooth explanation!!! U are a legend in my eyes!!
@rin0422
@rin0422 2 года назад
You really explained very clearly and I understand it to the point that I almost creat my own useState and useEffect. Thank you so much
@ericaguadalupe7862
@ericaguadalupe7862 Год назад
The fact that learning about useEffect dependencies can be summarized in such a clear, brief, and concise way blows my mind. This is amazing and helped me a LOT. Thank you. Edit: And it's only 4 minutes and 19 seconds long.
@joshrochon6243
@joshrochon6243 2 года назад
I've been watching you since 2018 bro. I can honestly say, I may not have made it in this profession if not for your videos. Thank you!
@christopherlucas1475
@christopherlucas1475 2 года назад
Brilliantly clear explanation mate! Many Thanks!
@rohan1765
@rohan1765 3 года назад
Great series , enjoying alot 👍🏼
@spes9850401
@spes9850401 9 месяцев назад
This is the best explaination I've seen so far
@sushantpatial9819
@sushantpatial9819 Год назад
These two videos on useEffect were amazing!
@tarekghosn3648
@tarekghosn3648 Год назад
thank you. every video takes me on the path of what im learning.
@Frankitoact
@Frankitoact 3 года назад
This React Tutorial is great! Thanks for a great job!!
@breakdancerQ
@breakdancerQ 2 года назад
I'm someone who understands things slowly and needs to watch something many times to get it. But this was just clear as day right of the bat!!
@sayedpritom
@sayedpritom Год назад
Excellently described the whole concept.
@akn9699
@akn9699 3 года назад
Love the Guru of Greatness !
@thendoronnyramashia749
@thendoronnyramashia749 2 года назад
Second video of yours that I'm watching and I already understand useEffect with dependacies better than the actual React documentation itself.
@dhansbisht9433
@dhansbisht9433 2 года назад
simple and to the point great video
@MrValVet
@MrValVet 20 дней назад
Awesome tutorial! Would like to see more app tutorials with React from you.
@alanmangroo3656
@alanmangroo3656 3 года назад
Thank you! You make this sound so simple. Is it bad to be enjoying these videos while I'm meant to be on holidays?
@AhmedAbukar
@AhmedAbukar 2 года назад
great man, I have learned a lot from you
@shashankrewankar2838
@shashankrewankar2838 3 года назад
Hey man, you tutorials are awesome!... the only thing I hate is that I have to wait for the next one to be uploaded 😋
@jorgeprograma
@jorgeprograma 11 месяцев назад
Once again, great explanation for both seasoned and beginner devs. Some instructors get into too much details early on instead of just teaching the stuff first. You excel at that!!
@NetNinja
@NetNinja 11 месяцев назад
Thanks Jorge :) that means a lot!
@CrookzArtwork
@CrookzArtwork 3 года назад
Thanks, man u the best Simple explanation well done Ninja
@rekahorvath3759
@rekahorvath3759 Год назад
Wow. I couldn't understand it clearly when I had learned it and now, I could understand it at the first try 😊
@isaiahdaniel2522
@isaiahdaniel2522 3 года назад
You are the boss shuan , thanks
@robdas1
@robdas1 11 месяцев назад
Simple clear explanation. Excellent!
@NetNinja
@NetNinja 11 месяцев назад
Thank you :) hope it was helpful!
@toannew
@toannew 3 года назад
Thank you for uploading this Serie. I am waiting for new episodes.
@UrinatingTheCrowd
@UrinatingTheCrowd 3 года назад
i bought an udemy course for reactjs and it sucks big time. so i went here instead. free and yet more comprehensive. you are a god
@woofcode3383
@woofcode3383 2 года назад
Thank you so very much for the quality content
@anasaljawa858
@anasaljawa858 3 года назад
Thank you, Shaun
@serdarinjo
@serdarinjo 3 года назад
Thanks bro, very nice explanation :)!
@joe86569
@joe86569 2 года назад
Wow such a nice Explanation
@parthipankalayini8
@parthipankalayini8 3 года назад
Awesome , Please do more React.js tutorial. TKS for your content .
@NitinSinghempirenitin
@NitinSinghempirenitin Год назад
You are truly a NINJA
@joelvilca2740
@joelvilca2740 Год назад
So grateful to you man, very clear! :D
@NetNinja
@NetNinja Год назад
Glad to hear that Joel!
@ryonwhyte
@ryonwhyte 2 года назад
Super helpful!
@learningit2572
@learningit2572 Год назад
I love you so much)) You are my teacher Splinter
@dankokozar
@dankokozar Год назад
This is brilliantly explained.
@NetNinja
@NetNinja Год назад
Thanks Danko!
@acha-jr
@acha-jr Год назад
I finally understand this well, thanks a lot mate
@NetNinja
@NetNinja Год назад
No problem 👍
@salahalhashmi6528
@salahalhashmi6528 3 года назад
thank you very much mr.ninja
@alcidesign
@alcidesign 8 месяцев назад
Yo! I just subscribed and liked. Now useEffect is so clear to me.
@NetNinja
@NetNinja 8 месяцев назад
Awesome, thank you :)
@engineeringwithmehran
@engineeringwithmehran 3 года назад
Hi net ninja, can you please link up the whole playlist in the description rather than making us to go to the channel to find it? I mean, it's fine but just a request if you can do so. BTW love your content and your JWT Authentication course was awesome, used it to create a course project login and sign up and also with help of some other sources got the email verification to work. ❤️
@mystickago
@mystickago 3 года назад
your amazing bro
@realtorBG
@realtorBG 3 года назад
probably u r the best
@avishekataur1710
@avishekataur1710 2 года назад
ah ! Man... Nice, Now I have a clear vision on useEffect
@GabrielGasp
@GabrielGasp 2 года назад
Is there a difference between using useEffect with no second argument or just leaving the code (like a console.log) inside the component function? As far as I can tell both cases will run in every re-render.
@sora6430
@sora6430 3 года назад
The useEffect without any parameter will render everytime I change something in the component? The entire component? If i pass some value through the useEffect, it will render when that specific state change? And the useEffect with a empty array will render only once when the component loaded?
@akashbhadouria6727
@akashbhadouria6727 3 года назад
How many videos will be in this series? And is this the only React series which we have to do leaving old playlists related to React?
@danhodson7187
@danhodson7187 3 года назад
Please include testing in this course! :)
@mriganksingh7586
@mriganksingh7586 3 года назад
concept made simple😎
@aperturemaker
@aperturemaker 8 месяцев назад
Hi ! Good tutorials. On line 21 : I had "WARNING in [eslint] src\Home.js > Line 21:7: React Hook useEffect has a missing dependency: 'blogs'. Either include it or remove the dependency array react-hooks/exhaustive-deps, so w/ a quick fix (i wanted to keep 'blogs' info) useEffect( () => { console.log ('useEffect ran'); console.log (blogs); },[blogs, name]);
@shashankmaheshwari3067
@shashankmaheshwari3067 11 месяцев назад
AMAZING
@candle-likeghost9523
@candle-likeghost9523 3 года назад
self-defined variable (let a = 1) cannot be the dependency of useEffect as it gives no effect even if the variable changes. I think useEffect is the best to pair with useState. I wonder if there have any other variable/const stuff that can be use as dependency for useEffect.
@SajjadAli_
@SajjadAli_ Год назад
king
@jv18creator
@jv18creator 3 года назад
❤️ cause I'm out of words
@LofiMusicStreaming682
@LofiMusicStreaming682 3 года назад
Love it
@chasec4897
@chasec4897 3 месяца назад
In a real world experience when would you need to re-render ? when should we add dependencies to the array ?
@subee128
@subee128 Год назад
Thanks
@MYMIND252
@MYMIND252 8 месяцев назад
🎯 Key Takeaways for quick navigation: 00:16 🔄 The `useEffect` hook can be configured to run a function after every component render, but sometimes you only want it to run under specific conditions. 00:41 🧩 To control when `useEffect` runs, you can use a dependency array as its second argument. An empty array means it only runs after the initial render and not on subsequent state changes. 01:25 🚀 You can specify dependencies in the array to make `useEffect` run whenever those dependencies change. For example, if you want to run it when a specific state variable changes, include that variable in the array. 03:14 📦 Dependencies in `useEffect` control when the function runs. If a dependency changes, the function runs. If a dependency remains constant, the function does not run again, even if you trigger state updates.
@indianlongboarder2844
@indianlongboarder2844 3 года назад
Hey there, I have an issue. Passing an array in dependencies causes infinite loop any help please. Tou can recreate it by passing any type of array in the dependencies. please help
@internap627
@internap627 3 года назад
Finally I understand the useEffect dependency.......I just used to play around till it worked 😅
@antoniofuller2331
@antoniofuller2331 2 года назад
LMAO
@Joe-pe8fe
@Joe-pe8fe 3 года назад
it would be great if you could make a React udemy course just like the javascript one with the projects and everything
@m3xpl4y
@m3xpl4y 2 года назад
does that mean that i can have for example 5 useEffects and each one will be fired when the prop set changes?
@mishkathossain2984
@mishkathossain2984 8 месяцев назад
what acutally is a render?? is it any time of web page redirector??!!!
@Mahmudulhasan-ts5hm
@Mahmudulhasan-ts5hm 3 года назад
thanks
@ozankurucu6261
@ozankurucu6261 3 года назад
This was an amazing explanation, thank you. I couldn't understand why it triggers for the first time for name state, it is not changing? Can you tell me and give me an example?
@amrishpandey2105
@amrishpandey2105 2 года назад
at first dependency is always empty. the initial value name is provided by you. so it will trigger for once because it changed from an empty array to name state. you can also think of it as default. it runs once by default if it is not an empty array. if it is an empty array it will not get triggered. if it has some initial state it will get triggered.
@okey1317
@okey1317 2 года назад
when do we pass functions inside the useffect array
@rohan1583
@rohan1583 Год назад
for me when using the useEffect hook, it runs twice during initial render, i found out that it is due to the project running in react strict mode which will render the project twice in dev mode. simply remove that to fix the issue
@mj2758
@mj2758 Год назад
or you can use useRef as well as a solution
@medamine194
@medamine194 2 года назад
if you made a react course in udemy definitely i will buy it
@Sollazzo08
@Sollazzo08 3 года назад
Great explanation! Anyone know any common use cases of this in the real world project?
@EnesKab
@EnesKab 2 года назад
The first thing i can imagine is, "once i delete a record, update the db accordingly."
@ridl27
@ridl27 3 года назад
ty.
@rafatadebanjo9731
@rafatadebanjo9731 2 года назад
Thank you so much for this course. Honestly, you are life saver. Please, i have a problem . My useEffect() is render twce once i reload the page. Please why is it behaving likethis. I even copied your code on github. it still render twice when i reload. Thanks alot
@chiefzaddy2880
@chiefzaddy2880 2 года назад
newer version of React has StrictMode which ran it twice on development environment for debugging purpose, it will be once in case of production mode
@rafatadebanjo9731
@rafatadebanjo9731 2 года назад
@@chiefzaddy2880 thank you very much. I appreciate it
@Mikef05316338
@Mikef05316338 2 года назад
Wicked
@jagrat12354
@jagrat12354 2 года назад
i was losing my mind when my use effect was run twice on initial render, turns out in dev mode react strict mode does it twice on initial render
@alexytou
@alexytou Год назад
Yeah, but using an empty array on useeffect is considered a bad practice and will cause an eslint warning. Also trying to call functions inside useffect and using the function as dependency and using usecallback in the function is also considered bad practice. So what can we do in those scenarios?
@surendrareddyseelam9757
@surendrareddyseelam9757 3 года назад
I want to add a dependency such that everytime I make a write call to backend that should trigger useEffect ,anyone please share your knowledge
@logeshwaran8776
@logeshwaran8776 2 года назад
why we use array [ ] as dependency , why can't use object, variable instead of array useEffect(() => { console.log('useEffect'); }, name or {name});
@window.location
@window.location 3 года назад
dependency warnings always makes me angry & fills up the terminal.
@BigTime929
@BigTime929 3 года назад
LOL 4 minutes and i understand it easily
@JohnSourvinos
@JohnSourvinos 3 года назад
01:58 A button at the bottom, or a bottom at the button? Greetings from LEO.
@usmanmughal5916
@usmanmughal5916 3 года назад
I hope u r not planning to do redux after this series by completely ditching vuex 4 with vue 3
@NetNinja
@NetNinja 3 года назад
I won't be doing Redux any time soon. I have other things to cover instead!
@igorr4682
@igorr4682 3 года назад
This is more like watch in vue js
@Gamerfan2000
@Gamerfan2000 Год назад
Anyone also having useEffect running twice upon initial render for some reason?
@edutainment9235
@edutainment9235 Год назад
yes, it's stopped me in my tracks. it wasn't happening and now I can't make it not stop
@edutainment9235
@edutainment9235 Год назад
the solution is down below @theLogic post (it's 8 months away this timestamp
@sarathchandramotati3260
@sarathchandramotati3260 2 года назад
useEffect ran 2 times in my browser. anyone facing same issue?
@akashnegi913
@akashnegi913 3 года назад
useEffect had a positive sideEffect Me .
@codewithHanbal
@codewithHanbal 3 года назад
4th comment
@fakuadegbenga9870
@fakuadegbenga9870 3 года назад
First comment
@salmon_is_decent8179
@salmon_is_decent8179 3 года назад
I am speed
@ckatke
@ckatke 3 года назад
1st Want a ❤️
Далее
Full React Tutorial #16 - Using JSON Server
5:11
Просмотров 326 тыс.
Sprinting with More and More Money
00:29
Просмотров 82 млн
Full React Tutorial #17 - Fetching Data with useEffect
7:55
Full React Tutorial #13 - Functions as Props
4:31
Просмотров 251 тыс.
Full React Tutorial #19 - Handling Fetch Errors
7:39
Просмотров 235 тыс.
Learn useMemo and React Memo for Faster Apps
10:02
Просмотров 69 тыс.
Full React Tutorial #14 - useEffect Hook (the basics)
3:56
Full React Tutorial #11 - Props
8:56
Просмотров 382 тыс.