쉐도잉 연습: Learn useMemo In 10 Minutes - 영상으로 영어 말하기 배우기

연습 모드 선택

각 모드는 전체 화면 연습실로 열립니다.

139 문장
문장이 너무 짧거나 길면 Edit를 눌러 조정하세요.
1
Hello everyone, welcome back to my React Hooks series, where in this video we're going to take a look at use memo,
2
how it works, and when you should actually use it.
3
And if you're interested in diving into React even deeper, make sure to check out my full
4
React course, which I'm going to link down in the description below.
5
Have you wanted free web hosting that doesn't suck?
6
Well you're in luck because today's video sponsor, Atlantic .net, is giving you an entire year -long free trial of their hosting.
7
And if you use the code
8
Kyle when you check out, you're going to get an additional $50 of credit that you can use towards whatever you want on the hosting platform.
9
On top of that, this hosting platform has powerful servers with great data reliability
10
and redundancy so you know that your site is going to be there and running with the data you want it to.
11
So make sure you use the code
12
Kyle in the link down in the description below to get your free hosting.
13
Welcome back to Web Dev Simplified.
14
My name's Kyle and my job is to simplify the web for you so you can start building your dream project sooner.
15
So if that sounds interesting, make sure you subscribe to the channel for more videos just like this.
16
Now to get started, I just have some really basic boilerplate code set up for us to test our application.
17
I'm going to walk through it real quick so you know exactly what we're doing.
18
I just have a simple single component called app, which has two pieces of state.
19
One is a number, which we can control by this input over here on the right.
20
And the second one is a Boolean for dark or light, which is toggled by this change theme button on the right side of our screen.
21
Then what we do is we have a function which doubles our number, so just multiplies by two, but this function is very slow.
22
If I scroll down here, you can see I just have a really long for loop
23
that just loops doing nothing for a really long time to emulate what would happen in a really slow, long -running, complex function.
24
Obviously, since this function just multiplies by two, all this code is doing is making the function really slow.
25
And if I change this number, for example, by clicking this up arrow, you're going to see it takes about a second,
26
half a second for it to actually double the number.
27
So you can see this function is quite slow to execute.
28
Now continuing onward, we just have a variable here,
29
which is taking this dark boolean and changing if we have a dark or light theme down here.
30
And then lastly, over here, we just have the output code which changes our number
31
when we update here and also toggles our theme when we click this button.
32
So that's just the basics of our code
33
and you may think okay this is fine code it's working great
34
and the slowness is you know not that bad
35
but it only is going to be slow when we update our number but actually that's incorrect thinking.
36
If we click our change theme button you're going to notice we have the same delay.
37
I'm going to click
38
it now you can see it takes about half a second
39
to a second for it to actually change the actual theme
40
and the reason for that is because when you update state in React, it's going to re -render your entire component.
41
So it's going to run this entire function from top to bottom,
42
which means that this slow function gets called every single time that we render our app component.
43
So whether we're changing the theme, whether we're actually updating the number here, or whether some other component is causing this component to re -render,
44
you're going to be forcing it to go through that slow function over and over and over again.
45
And this is a really big performance problem when you have these slow functions that don't really change that often.
46
So React has a built -in way to solve this with a hook which is called use memo.
47
So we can import this use memo hook just like this.
48
And memo here stands for memoization, which essentially is the idea of caching a value so you don't have to re -compute it every single time.
49
So in our example, this slow function here takes an input of number,
50
and it's always going to give us the same output every time we give it the same input.
51
So we can cache that input value number and the output it gives us.
52
That way if the number doesn't change we don't have to recalculate our slow function over and over and over again.
53
And the easy way to use this is we just call use memo and we're going to pass it in a function.
54
And this function is going to be the thing that we actually mem -wise.
55
So this is the thing that we're caching which in our case is going to be this slow function.
56
We just want to make sure we return this slow function here, get the result from it.
57
And then just like all of the other hooks that we talked about like useEffect for example, we're going to have a list of dependencies here.
58
And in our case the only dependency of this is going to be our number here.
59
Our number is the only thing that changes.
60
And when our number changes we need to rerun the code inside this useMemo hook
61
but if our number doesn't change we don't need to rerun this slow function code.
62
So with that one simple change let's save and see what happened to our app.
63
It's loading over here we can change this to for example one
64
and you can see it has a kind of delay change it up again it's going to have a delay.
65
When we click change theme you're going to notice this is instantaneous I can click it as much as I want to.
66
And that's because when we go through our code, we click change theme, it causes our component to re -render.
67
So it calls this function, does all this stuff, and it gets down to use memo.
68
And it says, well, our number is exactly the same as what it was last time.
69
So we're not going to recall this slow function here because we already know what the result is.
70
It's the exact same thing as it was last time.
71
So we're saving ourselves from having to recalculate this number with the slow function,
72
and we only are forcing ourselves to do this when we actually update this number inside of our input here.
73
So we're essentially only running this slow code when we have to, and not running it when we don't actually need to.
74
Now this seems really nice, and you may think, let me just use memo everywhere, why not just memwise everything?
75
Like this theme styles here, why don't I memwise that based on this dark boolean variable?
76
And the reason you don't want to memwise everything is because it does give you some performance overheads and some memory overhead.
77
For example, this use memo function must be called every single render of your component.
78
So you're calling an additional function.
79
And also it's saving the value, this previous value in some memory variable.
80
So you're forcing your memory to get larger every time you use memo
81
because you have to store an additional variable in memory to store that previous value.
82
Now this isn't a huge deal.
83
But especially where you don't need it,
84
it's going to cause additional memory usage and additional performance problems when just not using it would have been better.
85
So I highly recommend you only use memo in this case when you actually need the performance benefits, when the function you're calling is incredibly slow.
86
Then use memo is great.
87
But there's also a second use case for use memo, and that is something called referential equality.
88
And if you aren't really familiar with value versus reference in JavaScript.
89
I have a video on that topic I'll link in the cards in description.
90
But essentially what that is saying is when you try to compare two different variables in JavaScript,
91
it's going to compare their reference in the case of objects and arrays.
92
So for example, this theme styles here is a specific object.
93
And if I were to duplicate this theme styles, for example, theme styles two right here,
94
you would think that theme styles and theme style 2 are equal to each other, but in JavaScript they reference different objects.
95
They have the same values in the object, but the actual reference to the object itself is different.
96
So these two values are actually not equal to each other, which is something really important.
97
And as you know, inside of hooks in React, we have this array here of all of our dependencies, and when our dependencies change,
98
it's going to rerun our hook.
99
So let's take a quick example where we have a use effect
100
and we want to run this use effect every single time that our theme styles here changes.
101
So we're just going to have a really simple console .log
102
theme changed and down here inside of our dependencies I'm going to have our theme styles.
103
Let's just get rid of this console down here and of course we need to make sure we import use effect
104
just like that.
105
And now if I just really quickly inspect this page here, pull this over, go to the console,
106
you can see we get our theme changed being printed out.
107
And when we change our theme, you can see it's continually printing out theme changed.
108
But a problem you'll notice if I clear this out is when we change our number, it's also causing this theme change to be run.
109
And the reason for that is that referential equality.
110
What's happening is every time we run our function, we get a new theme styles object being created.
111
And this new theme style object is not the same as the old theme styles, even though they have the exact same values in the object,
112
they reference different places in memory.
113
And that's really important to know.
114
So in order to make sure that we only ever run useEffect when our theme style object actually gets re -updated, we can use memo again.
115
So what we can do is wrap this in a use memo, make sure you pass it a function,
116
and in here we're just going to return that object.
117
We just indent all this properly, and in here for our dependencies we're just going to put
118
that dark variable because that's the only thing that this object depends on.
119
Now if we were to rerun this you can see a change in our theme causes this to update our theme, logs it out, but
120
when we change our number you're going to notice we don't actually get anything printed in our console
121
and only when we click change theme.
122
And the reason for this is that now we are wrapping this object inside of memorization.
123
Essentially, if our dark variable doesn't change, we don't re -update our theme styles.
124
So we get the exact same reference as we had the previous time we rendered our app.
125
So now our use effect is comparing our old theme styles with our new theme styles, but they both reference the exact same object.
126
So these are the two big use cases for use memo.
127
The first and most obvious is when you want to make a slow function,
128
wrap it in this use memo so that it doesn't recompute every single time you render your component,
129
and it only computes when you actually need the value from that function since the input's actually changed.
130
The second use case, which is a little bit trickier, is this idea of referential equality.
131
Whenever you want to make sure the reference of an object
132
or an array is exactly the same as it was the last time you rendered if none of the internal workings changed,
133
you're going to want to use memo here to make sure
134
that you only update the reference of
135
that object whenever the actual contents of the object change instead of updating every single time you render.
136
And that's all there is to the use memo hook.
137
If you enjoyed this video, make sure to check out my full react course linked in the description to get a full overview of everything
138
you need to know about react.
139
Thank you very much for watching and have a good day.

앱 다운로드

유창하게 말하는 데 필요한 모든 것

AI 발음 평가문장마다 점수 확인
IPA 발음 연습모든 소리 마스터
단어 학습나만의 단어장 만들기
단어 게임놀면서 외우기

같은 채널

FOR YOU

추천 영상

이 레슨의 어휘와 말하기 포인트

이 말하기 레슨은 영상 “Learn useMemo In 10 Minutes”을(를) 바탕으로 합니다. 가장 자주 반복되는 단어는 다음과 같습니다: theme, function, memo, slow, object. 이 영상에는 섀도잉할 문장 139개와 단어 2166개가 있습니다. 말하는 구간의 길이는 10:41입니다. 화자는 분당 약 203단어로 빠르게 말하므로 연음과 약하게 발음되는 소리가 많습니다. 단어의 87%가 영어에서 가장 많이 쓰이는 3,000단어에 속해 어휘가 쉬운 편입니다.

이 영상의 핵심 어휘

영상에 나오는 익혀 둘 만한 단어 15개를 발음, 뜻과 함께 정리했습니다.

단어발음뜻
memo 명사/ˈmɛməʊ̯/메모
render 동사/ˈɹɛn.dɚ/일어나게 하다, 하게하다
hook 명사/hʊk/갈고리
component 명사/kəmˈpoʊ.nənt/부분
react 동사/ɹiːˈækt/반응하다
compare 동사/kəmˈpɛɚ/비교하다, 비유하다
output 명사/ˈaʊtpʊt/출력
delay 명사/dɪˈleɪ̯/지연, 지체
equality 명사/ɪˈkwɑ.lɪ.ti/평등, 균등
wrap 동사/ɹæp/싸다
cache 명사/kæʃ/캐시
loop 명사/luːp/고리
import 명사/ˈɪm.pɔɹt/수입품
topic 명사/ˈtɑpɪk/화제, 주제
server 명사/ˈsɝvɚ/서버, 봉사기

이 영상의 문법

화자가 가장 많이 쓰는 문형을 영상 속 실제 표현과 함께 정리했습니다.

문형영상 속 표현
수동태 be + 과거분사 — 누가 하는지보다 무슨 일이 일어나는지에 초점is toggled · is called · must be called
관계절 who / which + 절 — 사람이나 사물에 대한 추가 정보app, which has · light, which is · hook which is

주의할 발음

화자는 we're, you're, don't 같은 축약형과 약화된 형태를 48번 사용합니다. 들리는 대로 짧게 발음하세요.

  • “sh”와 “zh” 소리: essentially /ɪˈsɛnʃəli/, cache /kæʃ/, referential /ɹɛfəˈɹɛnʃəl/, memoization /ˌmɛmoʊaɪˈzeɪʃən/, memorization /ˈmem(ə)ɹaɪˌzeɪʃn̩/
  • 긴 단어 — 강세 위치에 주의: dependency /dɪˈpɛndənsi/, essentially /ɪˈsɛnʃəli/, equality /ɪˈkwɑ.lɪ.ti/, incredibly /ɪŋˈkɹɛdɪbli/, continually /kənˈtɪnjuəli/

한국어 화자가 어려워하는 소리:

  • /f/ — ㅍ(/p/)으로 바꾸지 말고 윗니를 아랫입술에 대기: referential /ɹɛfəˈɹɛnʃəl/, simplify /ˈsɪmplɪfaɪ/
  • /v/ — ㅂ(/b/)과 구별하기: variable [ˈvæɹ.i.ə.bl̩], overhead /ˈəʊvəˌhɛd/, server /ˈsɝvɚ/, solve /sɒlv/, versus /ˈvɝsəs/
  • /z/ — ㅈ이 아니라 성대를 울리는 /s/: memoization /ˌmɛmoʊaɪˈzeɪʃən/, memorization /ˈmem(ə)ɹaɪˌzeɪʃn̩/

이 영상으로 연습하는 방법

  1. 먼저 말하지 않고 영상을 끝까지 듣고 모르는 단어를 적어 둡니다.
  2. 0.75배속으로 한 문장씩 섀도잉을 시작하고, 익숙해지면 보통 속도로 돌아갑니다.
  3. 자신의 목소리를 녹음해 원본과 비교하고, memo, render, hook 같은 단어에 특히 주의합니다.

쉐도잉이란? 영어 실력을 빠르게 키우는 과학적 방법

쉐도잉(Shadowing)은 원래 전문 통역사 훈련을 위해 개발된 언어 학습 기법으로, 다언어 학자인 Dr. Alexander Arguelles에 의해 대중화된 방법입니다. 핵심 원리는 간단하지만 매우 강력합니다: 원어민의 영어를 들으면서 1~2초의 짧은 지연으로 즉시 소리 내어 따라 말하는 것——마치 '그림자(shadow)'처럼 화자를 따라가는 것입니다. 문법 공부나 수동적인 청취와 달리, 쉐도잉은 뇌와 입 근육이 동시에 실시간으로 영어를 처리하고 재현하도록 훈련합니다. 연구에 따르면 이 방법은 발음 정확도, 억양, 리듬, 연음, 청취력, 말하기 유창성을 크게 향상시킵니다. IELTS 스피킹 준비와 자연스러운 영어 소통을 원하는 분들에게 특히 효과적입니다.

섀도잉 방법: 단계별 전체 가이드 읽기 →