跟讀練習: 71k - 通過影片學習英語口語
選擇練習模式
每種模式都會開啟全屏練習室。
132 句
如果句子過短或過長,請點選 Edit 進行調整。
1
React is a JavaScript library full of fancy terms like reconciliation, composition, and error boundaries.
2
But what do all these terms actually mean?
3
Let's start from the beginning with components.
4
Components are the building blocks of every React app.
5
They allow us to make all the visible parts of our applications, like buttons, inputs, or even entire pages.
6
Just like Legos, you can use components as many times as you want.
7
Every React component is a JavaScript function that returns markup.
8
But since React is a JavaScript library, React components don't return HTML markup.
9
They actually return something called JSX, which is JavaScript in disguise.
10
JSX is optional, but the alternative way to make user interfaces is with the function createElement, which gets annoying to write pretty fast.
11
So everyone just uses JSX.
12
Since JSX is JavaScript, you can't write attributes like you would in HTML.
13
You have to write them in the camel case style.
14
That means HTML attributes like class become class name.
15
Unlike HTML, which is static and unchanging, the benefit of using React is that you can use dynamic JavaScript values in your JSX.
16
If you have data, you can display it in your JSX using curly braces.
17
Curly braces accept values like strings and numbers directly.
18
You can use them to make your attributes dynamic.
19
And you can style React elements using a JavaScript object within the curly braces.
20
Since JavaScript functions can only return one thing, in React you can only return one parent element from a component.
21
So you can't do this without getting a big error.
22
We could fix this by wrapping these components in a div, but maybe you don't want to add another element to the page.
23
Instead, you can use an empty component called a React fragment.
24
Okay, but what if I want to pass data into another component?
25
For that, you use something called props.
26
To make a prop, create a name on the component you want to pass data to
27
and set it equal to some value.
28
And that's it.
29
You can then use that prop in the component you passed it to.
30
Props refers to properties on an object, which is what you get in the parameters of each component.
31
To use the prop, take it from the object like a normal JavaScript property.
32
Think of them like custom attributes you can add to any component.
33
So wait, can you pass anything as a prop?
34
Yes, you can.
35
You can even pass other components as props using the children prop.
36
If you make opening and closing tags for a component, you can pass other components in between them.
37
These past components are called children, and you can access them on the children prop of the parent component.
38
And it's great for something called composition, which is about organizing our React components in the most optimal way.
39
The children prop is really useful for creating layout components when you want your children to have the same common layout.
40
The key prop is another built -in prop to React.
41
And no, unlike the name implies, it doesn't unlock anything interesting.
42
The key prop is used so React can tell one component apart from another, usually when you're creating a list with the map function.
43
A key is just a unique string or number to identify a component.
44
You'll usually know when you need to add a key because React will warn you in the console.
45
Fortunately, if you don't have a unique value for each item, you can always use the current index from the map function.
46
But how does React take all my amazing code and make it display something in the browser?
47
That process is called rendering.
48
React does this for us, but it's important to know how it works, because sometimes we can do a bad thing and cause it to infinitely re -render,
49
which crashes our app.
50
The way React knows how and when to render our application is using something called the virtual DOM, also known as the VDOM.
51
Okay, but what does DOM mean?
52
DOM stands for Document Object Model, which is what every browser uses to model all the HTML elements on a web page.
53
And when you draw it out, it kind of looks like a tree.
54
Here's the complete rendering process in React.
55
If the state of our React app changes, then React updates the virtual DOM, which is quicker to update than the real DOM.
56
Then, React uses a process called "diffing" to compare the updated virtual DOM to a previous version to see what's changed.
57
Once it sees what's different, React uses a process called "reconciliation" to update the real DOM with the changes that it found.
58
Whenever someone uses our app, tons of events take place like clicks, mouse movements, and key presses, many of which we need to detect.
59
Event handling is how we take those user events and do something with them.
60
React has a lot of built -in events such as OnClick, OnChange, and OnSubmit.
61
These three events are ones you'll probably use the most.
62
If we want to alert users when a button is clicked, we would add the onClick prop to the button and connect it to a function that would show that alert.
63
To manage data in our React apps, we need to use state, not that kind of state though.
64
State is like a snapshot from a camera.
65
It's a picture of our app at any given time.
66
To manage state, we also can't use JavaScript variables.
67
They don't cause our app to re -render.
68
Instead, we use special functions like useState and useReducer.
69
useState takes an argument that serves as the starting value of the state variable, which is likes in this example,
70
and returns an array containing the state variable and a function to update that state.
71
Using our button example, we could also update the number of times the button's been clicked with the update function,
72
setClicks, and display it in the button with the state variable likes.
73
Controlled components use state values to have more predictable behavior.
74
Here's an example of a controlled component where the value typed into the input is being put into state
75
and controlled by the state variable value.
76
Here's how it works.
77
The user types and set value puts what the user typed into state.
78
The state value is then updated and finally, the input uses that updated state as its value.
79
Controlled components are a great pattern to use because if we want to change the component's behavior, we just need to change the state that controls it.
80
UseState is an example of a React hook, which allow us to hook into features such as state within function components.
81
There are five main types of hooks.
82
State hooks like useState and useReducer help you manage state within React components.
83
Context hooks such as useContext let you use data pass through React context Ref hooks,
84
such as useref, let you reference things like HTML elements, Effect hooks, like UseEffect, let you connect with external systems like browser APIs,
85
and performance hooks like Use Memo and Use Callback, which can improve performance by preventing unnecessary work.
86
You'll use all of these hooks at some point, but the majority of the time you'll likely use just three hooks in your React components: useState, useEffect, and use ref.
87
When you think of the word purity, you might think of something like purified water.
88
Purity is a term used to describe how React components should work.
89
But this type of purity is more like how mathematical formulas are pure.
90
Pure React components mean that the same input should always return the same output.
91
To keep a React component pure, they should only return their JSX and not change any objects or variables that existed before rendering.
92
The cup component in this example is impure because it changes the variable count during render, which exists outside the component.
93
This leads to JSX having the wrong output when it is used more than once.
94
To help make sure we don't run into errors like this, we can use something called strict mode.
95
Strict mode is a special component which tells us about mistakes as we develop our React apps.
96
It's really convenient because it's just a component.
97
We usually wrap around our app component and it'll tell us when we really shouldn't do something.
98
But what if we need to do something outside our React app?
99
Your app might need to talk with the browser API, or make a request to a server.
100
If you do have an external system, you're going to need a way to step outside of React.
101
Effects are code that reach outside of our React application.
102
Usually effects, also known as side effects, can be done within event handlers.
103
For example, to make an HTTP request when you submit a form or click on a button.
104
If you can't run your effects within an event handler, then you can run them using the Use Effect hook.
105
For example, a common pattern is to fetch data when components first load with the useEffect hook.
106
Like effects, sometimes you want to step outside React and work directly with the DOM.
107
To reference an actual DOM element, you can use what's called a ref.
108
You can create a ref with the useRef hook, and to get access to a DOM element, use the ref prop on any React element.
109
For some tasks such as focusing an input, it's much easier to reference the actual DOM element instead of attempting to do it the React way.
110
Context is a powerful way to pass prop data through your app's components.
111
Most React apps have tons of nested components.
112
To get data down multiple levels involves passing the same props through components that don't actually need it.
113
Context lets us jump through the component tree and use data at any level without making props.
114
To use context, you first create context and apparent component, then wrap your parent component in a special context component called a context provider.
115
Put the data you want to pass down on the provider, And finally, access that data in any child component with the Use Context hook.
116
Portals, on the other hand, are kind of like context but for components.
117
Portals let you move React components into any HTML element you select.
118
Portals are great for components that can't be displayed properly because of their parents' component styles.
119
for example, for displaying modals, drop -down menus, and tooltips.
120
To create a portal, just use the Create Portal function pass your component to it, and choose the HTML element where you'd like your React component to appear.
121
Suspense is a special component that helps you handle loading a component or its data.
122
Suspense is helpful for components that take some time to fetch data.
123
It provides a better user experience to show a fallback component, like a loading spinner, until the data is available instead of nothing.
124
Suspense is also useful if you're lazily loading a component, which lets us load a component only when it's needed.
125
Since React apps are all JavaScript, errors that happen during rendering can totally break your app.
126
Error boundaries are components that let you catch app -breaking errors
127
and show a fallback component to tell the user about what happened.
128
For example, our app will crash if we run this code because it throws an error when there's no user.
129
To prevent our app from crashing, we'll first add an error boundary to display a fallback component, with a more helpful error message to be displayed to the user.
130
Now if you really want to dive deep into React, I've put together a complete bootcamp to help you master every one of these concepts from front to back.
131
You can get started now at reactbootcamp .dev.
132
I hope you learned a lot in this video, and I'll see you in the next one.
FOR YOU
推薦影片
背景與上下文
在這段影片中,我們深入探索了React這個流行的JavaScript庫的基本概念。影片講解者用通俗易懂的語言向觀眾介紹了元件、JSX、props等知識,這些都是構建React應用程式的基礎。這些內容不僅適合程式設計師瞭解React,還可以幫助英語學習者通過技術語言拓展詞彙。通過此影片,學習者能夠在理解新技術的同時提高英語發音和口語能力,特別是在處理與科技相關的主題時。
日常交流的五個重要短語
- components (元件) - 這是React應用的基礎組成部分。
- props (屬性) - 用於在元件間傳遞資料的重要概念。
- JSX (JSX語法) - 一種結合JavaScript和HTML的標記語言。
- rendering (渲染) - 將程式碼轉化為瀏覽器可視內容的過程。
- compose (組合) - 有效組織React元件的技巧。
逐步跟讀指南
理解和實踐影片內容是提高英語口語與發音的一個好方法。以下是一些循序漸進的步驟,幫助你在觀看影片時進行有效的跟讀:
- 初步觀看:觀看影片一次,瞭解大致內容和主題,不必過於關注每個術語。
- 逐段跟讀:將影片暫停,專注於每個短語和句子的發音,嘗試模仿講解者的語調與重音。特別注意“components”、“props”等詞彙的發音,以便在雅思口語練習中運用自如。
- 撰寫筆記:記錄下關鍵詞和短語,利用這些內容來提高口語表達。可以在日誌中寫下可以應用的實際場景,例如如何在程式設計交流中使用這些術語。
- 反覆練習:回放有難度的段落,使用shadowspeaks方法,將其與你的日常生活結合,形成對話。
- 應用與反饋:嘗試在與他人交流時使用新學的詞彙,特別是在技術討論中,收集他們的反饋幫助你進一步改進。
通過這種逐步跟讀的方式,你不僅能夠提高英語發音,還能夠在專業領域中自信地表達自己。無論是通過看YouTube學英語,還是在與朋友討論React時,持續的練習會讓你的口語能力顯著提高。
影片中的語法
說話人最常用的結構,並附上影片中的原話:
| 結構 | 影片中的用法 |
|---|---|
| 被動語態 be + 過去分詞 — 強調發生了什麼,而不是誰做的 | are called · is called · is clicked |
| 定語從句 who / which + 從句 — 補充說明人或事物 | JSX, which is · HTML, which is · object, which is |
| 現在完成時 have/has + 過去分詞 — 過去發生但與現在仍有關聯的事 | button's been clicked · I've put |
什麼是跟讀法?
跟讀法 (Shadowing) 是一種有科學依據的語言學習技巧,最初開發用於專業口譯員的培訓,並由多語言者Alexander Arguelles博士普及。這個方法簡單而強大:您在聽英語母語原聲的同時立即大聲重複——就像是一個延遲1-2秒緊跟說話者的影子。與被動聽力或語法練習不同,跟讀法強迫您的大腦和口腔肌肉同時處理並模模擬實的講話模式。研究表明它能顯著提高發音準確性,語調,節奏,連讀,聽力理解和口語流利度——使其成為雅思口語備考和真實英語交流最有效的方法之一。












