跟读练习: 10 Essential React Native Tips Every Developer Must Know - 通过视频学习英语口语
选择练习模式
每种模式都会打开全屏练习室。
184 句
如果句子过短或过长,请点击 Edit 进行调整。
1
You might have worked with React Native for quite some time, but do you really know all the ins and outs?
2
There are some really small nuggets of wisdom in the React Native docs
3
or from the day -to -day use that I want to share with you,
4
so here are 10 practical tips that you can use in your next
5
React Native project.
6
The first one is a real quick one about lists and something I shared before.
7
If you have an input here and you want to hide that keyboard, there's a simple thing that you can add to your list.
8
So I'm using a flat list here and you can now simply go ahead
9
and add the keyboard dismiss mode and set it to on drag.
10
As a result, I can drag the list and it will automatically close the hardware keyboard whenever I do the drag.
11
Additionally, by the way, you can also quickly make this a really cool animated list.
12
So I can add and remove things.
13
But let's just change this to an animated flat list from React Native Reanimated.
14
And then let's add the item layout animation and let's import the linear transition.
15
So now I should be able to have a smooth transition whenever I remove items
16
or add items with just two little changes to an animated flatlist
17
and the item layout animation and I can also on swipe close my keyboard.
18
The second tip is about the pressable component.
19
In most of my tutorials you're gonna see me use the touchable opacity which works great as a button replacement.
20
However if you are looking for a more extensive
21
and future -proof way to handle touch base input check out the pressable API
22
and if you go into the pressable you see
23
that there's a lot more fine -tuning
24
you can do like on press in on press out where
25
you can change the state of your components let's do a quick example i will just change these items
26
which are currently touchable opacity uh item to oppressable
27
and instead of just using styles item i can actually now use a function where i use the pressed state
28
and use that to set either the opacity
29
or for example the background color
30
and you can even use
31
this press state inside the child values here where I currently have the text of the pressable component.
32
As a result, I can now fine -tune exactly how the click event on
33
that button and how especially the press event works instead of just using a touchable opacity.
34
Tip number three is about dark modes and the appearance of our application.
35
Did you know that you can simply wrap your application using the theme provider from React Navigation
36
and then include the default theme
37
and the dark theme to automatically style the elements from react navigation
38
so in this case you're gonna see
39
that both the status bar uh the top area up here
40
and even the background here
41
because it's using the default background color are changing once i switch the colors here in the simulator this works
42
because we use the use color theme use color theme hook from react native
43
which then updates the color theme to either light or dark
44
and this is applied here in our check wrapped around our application.
45
You can then also drill this down on component level.
46
So whenever you want, you can simply import the color theme
47
and use it as a state to set different styles on your elements.
48
And if you manually want to toggle this, you can use the appearance API and the set color theme to manually save this.
49
This works nice in combination with something like async storage or MMKV.
50
So you can then manually on click toggle this.
51
However, in the simulator, this usually fails especially when I don't hit save
52
so now it should work and I can instantly and easily switch between light and dark mode in my app.
53
Tip number four is once again about colors this time it's about using platform
54
and the platform color API in the application
55
so here's a view with three different buttons and
56
if I go to
57
that same view on my Android emulator you're gonna see for some reason they look different
58
and the reason is
59
that you can use both platform select to switch between different platforms
60
you can actually not only have oh come on please stay open come on stay open
61
you can not only ah this is not possible not only switch between ios
62
and android but also windows mac os web or native
63
and then you can supply specific colors in your style sheet
64
and you can not only have fixed colors
65
but you can also see the platform color here
66
this is a bit more complicated to use especially figuring out the values for Android is somewhat hard
67
you have to get into the Android documentation but
68
if you're interested in this you can actually use the system colors of both iOS
69
and Android if you want a complete
70
and even more native feeling in your application tip 5 is about fonts
71
and especially Google fonts did you know that there's an expo package
72
that you can use that you can simply install
73
and then use all the fonts of google let's check
74
it out i've added the package for the frank rule libra uh font to my application to the layout
75
and i also use the use fonts hook to safely in
76
the beginning of my application load all the custom fonts
77
that i want to use i would usually use and use effect
78
and make sure fonts loaded is ready
79
but nonetheless i can now use them on my page inside of the font family
80
and as a result we see here the bold
81
and the medium one being applied
82
it has never been easier to use google fonts in your
83
react native application than this trust me tip number six is about images
84
when you use the image component
85
and you're loading something over the network for example a really big image like this it can sometimes take time
86
so if i go here it takes a millisecond
87
and there are sometimes images
88
that are even bigger now what you can do is you can actually specify a default source
89
and within that default source you basically set the image
90
that should be deployed a deployed should be displayed
91
while the first image is loading so
92
if I had it like this now I could go into the component
93
and you quickly saw that react native image
94
so I just used my local image because
95
that one should be instantly available you could also have like a simple loader in there as the default source
96
that would work as well and then you can use any kind of big image
97
and while it's loading just by default you display your default source in the image element.
98
Tip number seven is about the text element.
99
If you have a very long text in your application, there are different ways to improve this.
100
So the first way, if you're rendering really long text, is of course have this in a scroll view.
101
But sometimes you also want to limit the number of lines.
102
So you can do number of lines on the text element.
103
Let's set this to five.
104
And this will automatically render only five lines.
105
And at the end, you're going to have three dots.
106
So you don't need any logic if text length is bigger than 120, then render three dots or something.
107
No, you can just set the number of lines.
108
However, if you at the same time also want to still show all the things of your text, because now the text of girls truncated,
109
you could add a property called adjust font size to fit.
110
As a result, this looks quite interesting because in our example, well, eight lines is probably not enough.
111
But now we would be able to actually fit all of this in 20 lines of text
112
Remember this was our initial state
113
and now we would be able to render all of that using adjust font size to fit which will simply
114
Specify whether fun should be scaled down automatically to fit given style constraints
115
This is not always helpful, but it can be a nice fix in some of your applications
116
Tip number eight is about warnings in your application
117
So I recently came across a warning that was well not too interesting to me
118
Let's say you got this one
119
Which of course doesn't come up when I want to show it so encounter two children with the same name
120
Of course, that is something you definitely want to fix
121
However, sometimes there are things that you just want to ignore because they keep appearing
122
Especially if you maybe do a presentation for your customer what you can do is you can simply import lockbox
123
From react native we don't need these fences.
124
That looks interesting and now i could go ahead
125
and use lockbox uh and i got two um
126
or different ways i could ignore all locks
127
or i could ignore specific locks
128
so in my case what i want to ignore is probably encountered uh two children with the same key
129
i can now hit save and let's do a reload again
130
and i go into and boom no more locks
131
and of course the same would work
132
if i would use uh logbox .ignorealllocks that's probably a bit more dangerous uh
133
because it would hide anything that pops up in your application
134
so anyway treat this carefully but if you want some mind space some quiet applications
135
and nothing that pops up
136
while you work on your application simply use logbox to control the logs that appear in your react native app.
137
Tip number nine is about API usage and I was kinda shocked when I saw it.
138
So I was using a local API on localhost port 8080
139
and we see I have a simple block here where I fetch my data from API URL slash test
140
and it worked perfectly fine on iOS.
141
However on Android I get an error fetching data.
142
Why is that the case?
143
Well it turns out that localhost doesn't work on the Android emulator.
144
You gonna have a bad day.
145
What you can do as a result is you can add this little block at the top,
146
which is kinda ugly, but if you put all of your API calls, usually in one or two files,
147
into our custom hooks, that should be easy to treat.
148
So in my case, I grab the environment using the node environment to make sure we're actually running in development.
149
And if we're running in development and the platform is Android, I exchange and patch my API URL, which i usually got from my process environment
150
so instead of using localhost port 8080 i'm now using 10 .0 .2 .2 8080 let's hit save
151
and let's check out my emulator again so
152
if i now go into page 9 voila we have fixed this
153
and we can make api calls to localhost on both ios and android
154
Just as a quick addition to this, because this might be an ugly hack, here's something else that is recommended.
155
So you can also map your port using ADB or down here for ADB devices, you can map the port specifically for your emulator.
156
That's probably a tiny bit better than having additional code.
157
But if you just want to do a quick test, this one will get the job done.
158
Tip number 10 is for all of you who want to build a production application of your React Native application using Expo.
159
So usually you're gonna see you have your own custom defcline even if you do a pre -build
160
It only works when your live reload is up and running
161
But sometimes you just want to have the app installed and leave the room and show it to someone else
162
What you can do to build this kind of standalone application is once
163
you have created your pre -build with Expo Go into Xcode go up here hit edit scheme and under run configuration
164
Here for the build configuration you want to select release
165
Go ahead with that, build the application for your device and there's no more connection to a local server.
166
Additionally you can of course do the same for Android, so open your project up with Android Studio
167
and then at the bottom left you're gonna really small find something called build variants.
168
Inside of build variants you see that everything here is set to debug.
169
And of course for our app I can now change this to release, it would change all of these to release
170
and then I can go up here
171
and deploy the app to either my simulator
172
or of course any kind of connected android device all right
173
that brings us to the end of this quick video
174
I hope you enjoyed this quick run through of 10 different things
175
that I picked up over the years I took note of them
176
I probably will do another video once I reach more than five
177
or ten nodes again in the future
178
but let me know in the comments what is something that you figured out after years of using
179
React Native or you were like, why didn't I know that earlier?
180
Leave a comment down below.
181
And of course, also, if you enjoyed that build process step that I showed you last,
182
here's a video about all the ways how you can build your application with Expo, including pre -builds, EAS, and everything you need to know.
183
Don't forget to hit the like and subscribe button and I will catch you in the next one.
184
So until then, happy coding, Simon.
同频道
FOR YOU
推荐视频
本课的词汇与口语要点
这节口语课以视频“10 Essential React Native Tips Every Developer Must Know”为素材。 视频中反复出现的词有:application, color, react, native, android。 这段视频共有 184 个句子、2332 个单词可供跟读。 讲话部分时长为 12:00。 说话人语速较快,每分钟约 194 个词,会出现较多连读和弱读。 84% 的单词属于英语最常用的 3,000 词,其余的词建议在练习前先学一下。
视频中的重点词汇
视频中 15 个值得学习的单词,附发音和释义:
| 单词 | 发音 | 释义 |
|---|---|---|
| android 名词 | /ˈænˌdɹɔɪd/ | 人形機器人 /人形机器人, 仿生人 |
| font 名词 | /fɑnt/ | 字體 /字体, 字形 |
| default 名词 | /dɪˈfɔlt/ | 違約 /违约, 暴雷 |
| component 名词 | /kəmˈpoʊ.nənt/ | 元件, 部件 |
| element 名词 | /ˈɛləmənt/ | 要素 |
| ignore 动词 | /ɪɡˈnɔː/ | 無視 /无视, 忽略 |
| keyboard 名词 | /ˈki.bɔɹd/ | 鍵盤 /键盘 |
| custom 名词 | /ˈkʌstəm/ | 習慣 /习惯, 習俗 /习俗 |
| dragon 名词 | /ˈdɹæɡən/ | лун, 龍 /龙 |
| hook 名词 | /hʊk/ | 鉤 /钩, 鉤子 /钩子 |
| import 名词 | /ˈɪm.pɔɹt/ | 進口貨 /进口货, 舶來品 /舶来品 |
| layout 名词 | /ˈleɪ.aʊt/ | 設計 /设计, 佈局 /布局 |
| deploy 动词 | /dɪˈplɔɪ/ | 部署 |
| manually 副词 | /ˈmænj(u)əliː/ | 手动地 |
| simulator 名词 | /ˈsɪmjəˌleɪtɚ/ | 模拟器 |
视频中出现的短语动词
| 单词 | 发音 | 释义 |
|---|---|---|
| check out 动词 | 退房 | |
| figure out 动词 | 弄清楚 | |
| go ahead 动词 | /ˌɡoʊ əˈhɛd/ | 請便 /请便 |
| go up 动词 | 上昇 /上升, 上去 | |
| come up 动词 | 上來 /上来 | |
| pop up 动词 | 弹出 | |
| turn out 动词 | 原來 /原来 |
视频中的语法
说话人最常用的结构,并附上视频中的原话:
| 结构 | 视频中的用法 |
|---|---|
| 被动语态 be + 过去分词 — 强调发生了什么,而不是谁做的 | is applied · being applied · should be deployed |
| 现在完成时 have/has + 过去分词 — 过去发生但与现在仍有关联的事 | have fixed · i've added · has never been |
需要注意的发音
说话人用了 29 次缩略和弱读形式,例如 you're, gonna, don't。请按听到的简短形式来说。
- “th” 音: smooth /smuːð/, nonetheless /ˌnʌnðəˈlɛs/
- “sh” 和 “zh” 音: transition /tɹænˈzɪʃ.ən/, animation /ˌæn.ɪˈmeɪ.ʃən/, navigation /nævɪˈɡeɪʃən/, configuration /kənˌfɪɡ.əˈɹeɪ̯.ʃən/, shock /ʃɔk/
- 长单词——注意重音位置: manually /ˈmænj(u)əliː/, simulator /ˈsɪmjəˌleɪtɚ/, animation /ˌæn.ɪˈmeɪ.ʃən/, navigation /nævɪˈɡeɪʃən/, configuration /kənˌfɪɡ.əˈɹeɪ̯.ʃən/
中文母语者容易读错的音:
- /v/ — 不要读成 /w/,上齿轻触下唇: navigation /nævɪˈɡeɪʃən/, variant /ˈvæɹi.ənt/, server /ˈsɝvɚ/, provider /pɹəˈvaɪ.də(ɹ)/, voilà /(v)wɑˈlɑ/
- 词尾辅音 — 要读清楚,后面不要加元音: react /ɹiːˈækt/, android /ˈænˌdɹɔɪd/, font /fɑnt/, default /dɪˈfɔlt/, component /kəmˈpoʊ.nənt/
- /r/ 和 /l/ 的区别: practical /ˈpɹæk.tɪ.kəl/, carefully /ˈkɛɹf(ə)li/, replacement /ɹɪˈpleɪsmənt/, linear /ˈlɪn.i.əɹ/, drill /dɹɪl/
如何用这段视频练习
- 先完整听一遍视频,不要开口,记下不认识的单词。
- 先用 0.75 倍速逐句跟读,熟练之后再回到正常速度。
- 录下自己的声音并与原声对比,特别注意 android, font, default 这类单词。
什么是跟读法?
跟读法 (Shadowing) 是一种有科学依据的语言学习技巧,最初开发用于专业口译员的培训,并由多语言者Alexander Arguelles博士普及。这个方法简单而强大:您在听英语母语原声的同时立即大声重复——就像是一个延迟1-2秒紧跟说话者的影子。与被动听力或语法练习不同,跟读法强迫您的大脑和口腔肌肉同时处理并模仿真实的讲话模式。研究表明它能显着提高发音准确性,语调,节奏,连读,听力理解和口语流利度——使其成为雅思口语备考和真实英语交流最有效的方法之一。













