Learn useMemo In 10 Minutes

Learn useMemo In 10 Minutes

Web Dev Simplified

4 года назад

465,368 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@amitd1927
@amitd1927 - 02.11.2023 10:51

Howz it different from useEffect, as useEffect we can only run when certain value change.

Ответить
@miggu
@miggu - 30.09.2023 16:45

it's also important to note that if you need a calculation to run once, instead of using useMemo you could put the function in the argument of another useState, and save it there. As this is also a performance technique

Ответить
@abnow1998
@abnow1998 - 22.09.2023 21:53

Dude, I have been watching your videos from past 1-2 yrs, Y don't you dump your entire courses on Pluralsight or Udemy man!! It's worth the pay.

Ответить
@RafalStefanowicz
@RafalStefanowicz - 14.09.2023 07:00

great job

Ответить
@cordial
@cordial - 13.08.2023 18:09

In the second example, couldn't you just use a useEffect on the dark useState?

Ответить
@Samuel-sc9qi
@Samuel-sc9qi - 02.08.2023 14:32

Correct me if I'm wrong:
'useMemo' return every time new 'themeStyles' object -> every time 'dark' changes new 'themeStyles' object is created -> You can move 'useMemo' dependencies to 'useEffect' without any useMemo needed.

I understand that dependencies can be confusing without 'useMemo', but in this app it's correct to use:
const themeStyles = {
backgroundColor: dark ? 'black' : 'white',
color: dark ? 'white' : 'black'
}
useEffect(() => {
console.log('Theme Changed')
}, [dark])

Ответить
@LEGnewTube
@LEGnewTube - 01.08.2023 16:11

Clear as crystal. Thank you for the vid!

Ответить
@faiz.c1007
@faiz.c1007 - 30.07.2023 18:37

Great video

Ответить
@soumyaranjan1433
@soumyaranjan1433 - 29.07.2023 17:27

Honestly I use test exact code , but not see any changes

Ответить
@ErShikharChauhan
@ErShikharChauhan - 22.07.2023 21:41

how easily u make things make sense 👏

Ответить
@yassiracaf9067
@yassiracaf9067 - 17.07.2023 17:33

oooh that was the best explanation i've seen so far

Ответить
@krils9984
@krils9984 - 02.07.2023 06:31

Thank you so much. I'm doing a project for my school and you just saved me my ass!

Ответить
@tylermorris84
@tylermorris84 - 29.06.2023 03:25

Edzack ... edzackly ... edzack values.... is that how he's spelling it?

Ответить
@preciousdim7484
@preciousdim7484 - 27.06.2023 19:17

Please how effective would it be to use useEffect to fetch data from an api with an empty dependency array and use useMemo to watch for change and update accordingly, I would like to know if this practice would work and how effective it would be as I have my useEffect rerendering endlessly anytime I put the state of the response in its dependency array

Ответить
@alan208
@alan208 - 27.06.2023 12:56

W teacher

Ответить
@karim6179
@karim6179 - 22.06.2023 05:36

i literally been searching in udemy for a course that explain react hooks like this saw couple of videos but none of theme get to that great content quality feels guilty to get that for free thanks man

Ответить
@AmanMavi1
@AmanMavi1 - 19.06.2023 09:35

watching your video before i got the job, watching ur video after i got the job

Ответить
@jamjam3448
@jamjam3448 - 01.06.2023 20:22

nice hair

Ответить
@timelapsegeek
@timelapsegeek - 01.06.2023 13:39

perfectly explained

Ответить
@abdulmuneebafridi4437
@abdulmuneebafridi4437 - 12.05.2023 13:48

Appreciate your effort , well thanks for providing effective content

Ответить
@skandarsouissi7282
@skandarsouissi7282 - 30.04.2023 02:18

Can you link react hooks to their docs in the blog that would be very useful, thanks <3

Ответить
@ralphstube
@ralphstube - 24.04.2023 14:10

To make the 'slowFunction' slow the console.log needs to go inside the for loop:

function slowFunction(num) {
for (let i = 0; i <= 5000; i++) {
console.log("Calling Slow Function");
}
return num * 2;
}

otherwise it's just counting, which isn't noticably slow.
I was staring at it for ages, thinking "this isn't really slow" - take the count way down, try 1,000 and gradually increase.

Ответить
@billwu7367
@billwu7367 - 20.04.2023 09:23

you are a skillful and smart ,patient youngster

Ответить
@by-Murat
@by-Murat - 13.04.2023 23:06

thats great, first example and second explain the issue great way. After first one , I told myself hah what is the different between useEffect and useMemo then I got answer :D In that way as far as understand if use useEffect with array or object it is useless and we have to use useMemo ?

Ответить
@user-up1uf2nl2z
@user-up1uf2nl2z - 11.04.2023 08:57

thanks bro ,, I understand very well ..

Ответить
@elhaambasheerch7058
@elhaambasheerch7058 - 08.04.2023 15:35

The amount of clarity Kyle gives while explaining complex concepts is truly unmatched, certainly my go to channel to learn tough concepts.

Ответить
@sieve5
@sieve5 - 04.04.2023 10:05

This is awesome!!!

Ответить
@vvbhargav5854
@vvbhargav5854 - 23.03.2023 00:47

@Anyone in referential contradiction or something why not use the dark variable in the use effect itself its a much simpler solution than to memorize let me know @All

Ответить
@kvenkateshprasad8866
@kvenkateshprasad8866 - 20.03.2023 21:29

cant we use useEffefct and pass number in the dependency array and call the function inside it. so that only when number changes, function gets triggered. ?

Ответить
@shrikant_paliwal
@shrikant_paliwal - 19.03.2023 17:44

Awesome explaination

Ответить
@sushanthnukala2678
@sushanthnukala2678 - 15.03.2023 13:04

Regarding the first use case, can't we achieve the same using useEffect? running a function only when a certain variable (state variable or prop variable) changes. what is the main difference between using useEffect and useMemo in that first scenario

Ответить
@DungLearnThings
@DungLearnThings - 06.03.2023 18:29

awesome work kyle 🤩

Ответить
@ibrahimyoussef4489
@ibrahimyoussef4489 - 02.03.2023 18:10

yoooooooooou aaaaaaaaaare awesomeeeeeee

Ответить
@notcountdankula
@notcountdankula - 25.02.2023 21:19

Best video about useMemo on internet

Ответить
@KILLCHRISU
@KILLCHRISU - 05.02.2023 08:44

Beautifully explained as usual Kyle

Ответить
@knuseski
@knuseski - 27.01.2023 17:41

But you can use useEffect twice intead of useMemo, it will be the same...right? Or I'm missing something...

Ответить
@thetech3624
@thetech3624 - 23.01.2023 21:57

So basically useEffect runs everything inside its body and re-renders everything on the page based on the dependency being triggered, while useMemo runs everything inside its body but only re-renders the parts of the app that connect to its return statement based on the dependency being triggered, right?

Ответить
@howardlee3394
@howardlee3394 - 21.01.2023 06:25

Thanks

Ответить
@fbiindia9661
@fbiindia9661 - 28.12.2022 18:05

you are a legend Sir! going through a Meta certified frontend course and they did a pretty bad job at explaining memo, I already knew where I have to come to understand it better and I was correct.

Ответить
@Demmynile
@Demmynile - 27.12.2022 18:35

very nice explaination

Ответить
@hayveno
@hayveno - 27.12.2022 16:15

Well explained, Kudos Kyle.

Ответить
@davitkolxi2632
@davitkolxi2632 - 16.12.2022 11:40

Great video as always! 🔝
Question: I've read that use memo should be used only when calculations are heavy performance wise.. I didn't get why? Could you explain?

Ответить
@anthonysim563
@anthonysim563 - 15.12.2022 09:24

This was an excellent explanation! Thank you!

Ответить
@samislam2746
@samislam2746 - 14.12.2022 16:03

1- What is the difference between react useMemo and React.Memo.
2- What is the difference between lodash memoize method and react useMemo?

Ответить
@jovantancevski7629
@jovantancevski7629 - 13.12.2022 23:00

Best UseMemo video I've seen so far, good job Kyle !

Ответить
@garcipat
@garcipat - 11.12.2022 22:07

Do you ahve a video where you point out the differecnce betwee useMemo and useEffect?

Ответить