All language subtitles for 004 Working with Breakpoints_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,400 --> 00:00:05,430 So we have a pretty much logical error here 2 00:00:05,430 --> 00:00:06,470 in our code. 3 00:00:06,470 --> 00:00:09,220 We have the problem that we have the hard coded ID 4 00:00:09,220 --> 00:00:10,330 and we already learned 5 00:00:10,330 --> 00:00:13,780 how we can find and fix this error. 6 00:00:13,780 --> 00:00:17,170 Now let's say we didn't use any of the other two approaches. 7 00:00:17,170 --> 00:00:19,030 We overlooked that warning 8 00:00:19,030 --> 00:00:22,370 and we don't know why it's behaving incorrectly. 9 00:00:22,370 --> 00:00:23,710 In such cases, 10 00:00:23,710 --> 00:00:25,960 if you can't find the error otherwise 11 00:00:25,960 --> 00:00:28,400 or if you just prefer this approach maybe, 12 00:00:28,400 --> 00:00:30,860 you can go to the sources tab here 13 00:00:30,860 --> 00:00:33,160 in the browser developer tools 14 00:00:33,160 --> 00:00:35,520 and there you find in the end the source files 15 00:00:35,520 --> 00:00:38,300 that are being used on this webpage right now. 16 00:00:38,300 --> 00:00:40,350 And that includes your JavaScript code. 17 00:00:40,350 --> 00:00:41,610 And the cool thing is 18 00:00:41,610 --> 00:00:43,740 that this React development process, 19 00:00:43,740 --> 00:00:45,630 this NPM start script here, 20 00:00:45,630 --> 00:00:46,950 which runs in the end 21 00:00:46,950 --> 00:00:49,340 is set up such that it, 22 00:00:49,340 --> 00:00:52,740 of course pushes code to the browser 23 00:00:52,740 --> 00:00:54,990 that is executable by the browser. 24 00:00:54,990 --> 00:00:57,760 But it also gives the browser extra information 25 00:00:57,760 --> 00:01:01,240 which the browser developer tools are able to pick up 26 00:01:01,240 --> 00:01:04,569 to allow us to actually debug our code 27 00:01:04,569 --> 00:01:07,610 in the raw form we wrote it in. 28 00:01:07,610 --> 00:01:09,730 so that we are able to debug with that code 29 00:01:09,730 --> 00:01:11,310 we're writing in these files, 30 00:01:11,310 --> 00:01:13,880 even though that technically isn't the code 31 00:01:13,880 --> 00:01:16,230 that's executed by the browser. 32 00:01:16,230 --> 00:01:17,960 So this React development process, 33 00:01:17,960 --> 00:01:19,470 gives the browser a bridge, 34 00:01:19,470 --> 00:01:21,440 between the code that runs in the browser 35 00:01:21,440 --> 00:01:23,400 and the code we wrote, 36 00:01:23,400 --> 00:01:25,180 and we can access this code here 37 00:01:25,180 --> 00:01:27,150 in the sources tab, 38 00:01:27,150 --> 00:01:29,830 by going to that User's folder 39 00:01:29,830 --> 00:01:31,200 which you should see. 40 00:01:31,200 --> 00:01:32,670 Users, your username 41 00:01:32,670 --> 00:01:34,290 and then a source folder. 42 00:01:34,290 --> 00:01:38,240 And in there you find your React files. 43 00:01:38,240 --> 00:01:42,213 The files we actually also have here in our IDE. 44 00:01:43,950 --> 00:01:45,150 Now, if you don't find it here, 45 00:01:45,150 --> 00:01:47,330 you can also check out that Webpack folder 46 00:01:47,330 --> 00:01:49,810 and there you might also find a source folder 47 00:01:49,810 --> 00:01:52,010 with your source files. 48 00:01:52,010 --> 00:01:54,930 You can look around because sometimes it's located 49 00:01:54,930 --> 00:01:57,820 in a different node in a different sub folder 50 00:01:57,820 --> 00:02:00,210 but somewhere here in the sources tab, 51 00:02:00,210 --> 00:02:02,900 in this tree of files and folders 52 00:02:02,900 --> 00:02:05,263 you should find your original source code. 53 00:02:06,280 --> 00:02:08,070 And then you could always dive 54 00:02:08,070 --> 00:02:10,880 into the different parts that you wanna analyze. 55 00:02:10,880 --> 00:02:13,210 You could go into the CourseGoalItem 56 00:02:13,210 --> 00:02:15,540 and there, for example, the deleteHandler 57 00:02:15,540 --> 00:02:18,330 and simply add a break point by clicking 58 00:02:18,330 --> 00:02:21,500 onto the line number where you wanna add it. 59 00:02:21,500 --> 00:02:23,930 In this case, that deleteHandler function 60 00:02:23,930 --> 00:02:26,550 which is triggered when we click on the list item 61 00:02:26,550 --> 00:02:29,600 because that's where the deletion process starts. 62 00:02:29,600 --> 00:02:32,520 So maybe that is where we wanna pause the code 63 00:02:32,520 --> 00:02:35,050 and then step through the code step by step 64 00:02:35,050 --> 00:02:36,803 so that we can find the problem. 65 00:02:37,890 --> 00:02:39,680 Once you add such a break point 66 00:02:39,680 --> 00:02:41,660 if you then execute that action, 67 00:02:41,660 --> 00:02:43,760 that triggers that code part 68 00:02:43,760 --> 00:02:45,710 where the break point is placed. 69 00:02:45,710 --> 00:02:50,600 Code execution stops once it reaches that break point line. 70 00:02:50,600 --> 00:02:51,560 So you see that here, 71 00:02:51,560 --> 00:02:53,300 it's paused in a debugger 72 00:02:53,300 --> 00:02:56,090 and that line is now highlighted in blue here 73 00:02:56,090 --> 00:02:57,850 and you've got surrounding information 74 00:02:57,850 --> 00:02:59,690 in those boxes at the bottom. 75 00:02:59,690 --> 00:03:01,220 For example, you see variables 76 00:03:01,220 --> 00:03:02,690 which are currently available. 77 00:03:02,690 --> 00:03:05,593 You see the Call Stack and so on. 78 00:03:06,680 --> 00:03:08,150 And now you can do something cool. 79 00:03:08,150 --> 00:03:12,150 You can step through your code step by step. 80 00:03:12,150 --> 00:03:15,270 And for example, here we call the onDelete method 81 00:03:15,270 --> 00:03:17,680 on the props object, for example. 82 00:03:17,680 --> 00:03:20,170 So to have a look at what's going on there 83 00:03:20,170 --> 00:03:24,260 we can use this Step into next function call button. 84 00:03:24,260 --> 00:03:27,110 If you click that we're in the deleteItemHandler 85 00:03:27,110 --> 00:03:28,950 which is the function that was triggered 86 00:03:28,950 --> 00:03:30,853 because of that props concept. 87 00:03:31,730 --> 00:03:34,616 And here we see that setCourseGoals function 88 00:03:34,616 --> 00:03:36,170 which is being called 89 00:03:36,170 --> 00:03:39,060 and you can also hover over variables here 90 00:03:39,060 --> 00:03:41,540 to see the values that are currently stored in them. 91 00:03:41,540 --> 00:03:44,470 And for example, if I hover over goalId here 92 00:03:44,470 --> 00:03:46,773 I see that it is goal1. 93 00:03:48,000 --> 00:03:51,490 Now, this might or might not help me here, 94 00:03:51,490 --> 00:03:53,950 but I can see that I have goal1 here 95 00:03:53,950 --> 00:03:55,640 when I clicked on this goal 96 00:03:55,640 --> 00:03:58,520 which was actually the second goal I added. 97 00:03:58,520 --> 00:04:03,080 Now we can use the Step over next function call button here 98 00:04:03,080 --> 00:04:06,910 to finish that setCourseGoals function call. 99 00:04:06,910 --> 00:04:08,040 So now with that, 100 00:04:08,040 --> 00:04:10,940 the deleteItemHandler basically finished 101 00:04:10,940 --> 00:04:12,720 and information we got is that 102 00:04:12,720 --> 00:04:15,750 we have the goalId goal1 103 00:04:15,750 --> 00:04:17,209 for that goal we deleted 104 00:04:17,209 --> 00:04:18,890 which as we of course know, 105 00:04:18,890 --> 00:04:20,733 is the wrong goal to delete. 106 00:04:21,870 --> 00:04:24,690 So now we could resume script execution 107 00:04:24,690 --> 00:04:26,890 because we're done with this debugging cycle 108 00:04:26,890 --> 00:04:28,130 and simply try this again 109 00:04:28,130 --> 00:04:29,960 and click on the next goal. 110 00:04:29,960 --> 00:04:32,480 And dive into the next function call here 111 00:04:33,490 --> 00:04:37,030 and see that here we have the same goalId as before. 112 00:04:37,030 --> 00:04:39,560 So now this should be a point where we see, 113 00:04:39,560 --> 00:04:40,420 wait a second, 114 00:04:40,420 --> 00:04:43,140 if we have to same ID on two different goals 115 00:04:43,140 --> 00:04:44,510 on which I clicked here 116 00:04:44,510 --> 00:04:46,090 that seems to be the problem 117 00:04:46,090 --> 00:04:48,640 why the wrong goal was deleted. 118 00:04:48,640 --> 00:04:50,240 So that's maybe with a point 119 00:04:50,240 --> 00:04:52,920 where we resume script execution 120 00:04:52,920 --> 00:04:54,710 and then dive back into the code 121 00:04:54,710 --> 00:04:56,370 where we actually add goals 122 00:04:56,370 --> 00:04:58,700 because that is where we set our IDs. 123 00:04:58,700 --> 00:05:00,410 And just by looking at that code, 124 00:05:00,410 --> 00:05:02,030 we of course should be able to see 125 00:05:02,030 --> 00:05:05,363 why we have goal1 for every goal. 126 00:05:06,220 --> 00:05:08,080 So that's how we can use the break points 127 00:05:08,080 --> 00:05:10,530 to step for our codes step by step 128 00:05:10,530 --> 00:05:12,310 and even inspect values 129 00:05:12,310 --> 00:05:14,350 which are stored in variables and so on 130 00:05:14,350 --> 00:05:18,493 to find out why something behaves the way it does behave. 131 00:05:19,410 --> 00:05:21,050 So break points, 132 00:05:21,050 --> 00:05:23,430 and you can always clear them by clicking on them again. 133 00:05:23,430 --> 00:05:25,740 Break points are another useful tool 134 00:05:25,740 --> 00:05:28,280 for analyzing your code for understanding it 135 00:05:28,280 --> 00:05:31,600 and for finding and fixing errors like that. 136 00:05:31,600 --> 00:05:33,160 And with that, I'll revert this 137 00:05:33,160 --> 00:05:35,080 to Math.random.toString 138 00:05:35,080 --> 00:05:38,040 which of course then is an ID we can use 139 00:05:38,040 --> 00:05:39,640 without getting that warning. 140 00:05:39,640 --> 00:05:41,710 Now, if I try this again, 141 00:05:41,710 --> 00:05:44,020 you see I don't get to the warning. 142 00:05:44,020 --> 00:05:45,760 If I now add multiple goals, 143 00:05:45,760 --> 00:05:47,310 you see if I click on the first goal, 144 00:05:47,310 --> 00:05:49,210 I delete the first goal. 145 00:05:49,210 --> 00:05:50,780 So this now works, 146 00:05:50,780 --> 00:05:52,920 and that's another important set of tools. 147 00:05:52,920 --> 00:05:55,930 The debugging tools you've got natively in your browser 148 00:05:55,930 --> 00:05:58,280 Here I showed it in the Chrome browser 149 00:05:58,280 --> 00:06:01,483 but you also have similar tools in Firefox or Safari. 11162

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.