Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,270 --> 00:00:03,950
So with that error solved
2
00:00:03,950 --> 00:00:05,770
the application is running again.
3
00:00:05,770 --> 00:00:07,700
Now I can start adding goals again
4
00:00:07,700 --> 00:00:12,160
for example, Master React.
5
00:00:12,160 --> 00:00:14,233
And also let's say,
6
00:00:15,560 --> 00:00:20,560
Check out other courses on React.
7
00:00:20,570 --> 00:00:22,290
Now I added these goals
8
00:00:22,290 --> 00:00:24,223
and now I actually also have
9
00:00:24,223 --> 00:00:26,640
another error in this application.
10
00:00:26,640 --> 00:00:29,080
Another error, which won't lead
11
00:00:29,080 --> 00:00:30,750
to a compilation error here
12
00:00:30,750 --> 00:00:32,140
and which won't show up here
13
00:00:32,140 --> 00:00:33,830
on the main screen though.
14
00:00:33,830 --> 00:00:36,210
If I delete my newly added
15
00:00:36,210 --> 00:00:39,410
Check out other courses on React goal,
16
00:00:39,410 --> 00:00:40,830
you see it's there.
17
00:00:40,830 --> 00:00:43,760
Actually the other goal I added was deleted
18
00:00:43,760 --> 00:00:46,030
even though I clearly clicked on
19
00:00:46,030 --> 00:00:48,593
the Checkout other courses on React goal.
20
00:00:49,880 --> 00:00:52,110
So since that worked before
21
00:00:52,110 --> 00:00:53,830
in the other course modules
22
00:00:53,830 --> 00:00:56,000
there has to be something in my code
23
00:00:56,000 --> 00:00:58,330
that is causing this error.
24
00:00:58,330 --> 00:01:00,730
So what could be the problem here?
25
00:01:00,730 --> 00:01:03,030
I'm not getting an error message here on the screen
26
00:01:03,030 --> 00:01:05,250
not here in the terminal either.
27
00:01:05,250 --> 00:01:07,313
So how can we now solve such error?
28
00:01:08,270 --> 00:01:10,350
Well, there are a couple of things you can do.
29
00:01:10,350 --> 00:01:13,040
A couple of steps that are worth a try.
30
00:01:13,040 --> 00:01:14,670
Let's first of all go to the place
31
00:01:14,670 --> 00:01:17,220
where we have that deletion logic.
32
00:01:17,220 --> 00:01:19,310
We got our course goal list
33
00:01:19,310 --> 00:01:21,550
and there we have on the lead
34
00:01:21,550 --> 00:01:24,700
where we trigger props on the lead item.
35
00:01:24,700 --> 00:01:26,100
If you go into a course goal
36
00:01:26,100 --> 00:01:28,084
item we see on the lead
37
00:01:28,084 --> 00:01:31,040
is in the end triggered when we click on that.
38
00:01:31,040 --> 00:01:32,810
I don't really see an error here
39
00:01:32,810 --> 00:01:36,200
with our forwarding that ID in course goal list.
40
00:01:36,200 --> 00:01:39,110
We just pass on that event in the end to
41
00:01:39,110 --> 00:01:42,620
on the lead item, on the course goal list component.
42
00:01:42,620 --> 00:01:44,480
So if you go to the app component
43
00:01:46,440 --> 00:01:48,550
where this ultimately is being rendered,
44
00:01:48,550 --> 00:01:51,680
we see that the delete item handler is executed
45
00:01:51,680 --> 00:01:53,100
and there we get the goal ID
46
00:01:53,100 --> 00:01:55,550
and we delete a goal.
47
00:01:55,550 --> 00:01:59,750
Now a goal was deleted as we saw just the wrong one.
48
00:01:59,750 --> 00:02:02,750
So did the leash logic in general seems to work,
49
00:02:02,750 --> 00:02:04,743
but maybe the ID is wrong.
50
00:02:05,610 --> 00:02:07,804
So maybe we should go to the place
51
00:02:07,804 --> 00:02:11,270
where the IDs are generated and assigned.
52
00:02:11,270 --> 00:02:14,040
And that's here in the add Goal Handler.
53
00:02:14,040 --> 00:02:15,890
And here indeed, I changed something.
54
00:02:16,830 --> 00:02:21,170
I set my ID to a hard-coded string.
55
00:02:21,170 --> 00:02:23,620
Previously here I used math random
56
00:02:23,620 --> 00:02:27,230
to derive a pseudo unique ID.
57
00:02:27,230 --> 00:02:29,130
Now with the hard-coded string
58
00:02:29,130 --> 00:02:32,010
I introduced a logical error here.
59
00:02:32,010 --> 00:02:37,010
The error is that I assigned the same ID to all goals.
60
00:02:37,040 --> 00:02:41,250
So therefore they're no longer distinguishable by ID.
61
00:02:41,250 --> 00:02:43,160
And hence, if we click on a goal
62
00:02:43,160 --> 00:02:45,020
the first goal that has the ID
63
00:02:45,020 --> 00:02:47,860
which is found in the goals array, is deleted.
64
00:02:47,860 --> 00:02:50,550
And that's always the first goal I ever added.
65
00:02:50,550 --> 00:02:52,740
That's why not this goal was deleted
66
00:02:52,740 --> 00:02:54,573
but the goal which I added before.
67
00:02:55,440 --> 00:02:57,370
So that's a logical mistake
68
00:02:57,370 --> 00:02:59,420
and I was able to narrow it down
69
00:02:59,420 --> 00:03:02,920
by going through that complete chain of events.
70
00:03:02,920 --> 00:03:05,670
Click on a goal, we triggered a deletion handler
71
00:03:05,670 --> 00:03:08,010
and I had to look at all those steps
72
00:03:08,010 --> 00:03:09,580
to narrow down the problem
73
00:03:09,580 --> 00:03:12,030
to finally find this problem here.
74
00:03:12,030 --> 00:03:15,363
And this is a perfectly fine way of trying to solve this.
75
00:03:16,340 --> 00:03:19,010
Now here's another thing that could help you.
76
00:03:19,010 --> 00:03:21,150
If I add goals again.
77
00:03:21,150 --> 00:03:25,980
Check out other courses on React
78
00:03:28,120 --> 00:03:30,283
and Master React.
79
00:03:31,530 --> 00:03:32,690
If I do that
80
00:03:32,690 --> 00:03:34,187
and I again click on the first goal
81
00:03:34,187 --> 00:03:36,080
and the second one is deleted.
82
00:03:36,080 --> 00:03:38,340
Let's now open up the developer tools here
83
00:03:40,520 --> 00:03:43,760
And there, let's have a look at the console,
84
00:03:43,760 --> 00:03:46,760
the JavaScript development and debugging console.
85
00:03:46,760 --> 00:03:48,730
Here the browser gives us any
86
00:03:48,730 --> 00:03:50,880
logging messages we added to our code
87
00:03:50,880 --> 00:03:52,620
and also some warnings and errors
88
00:03:52,620 --> 00:03:54,300
that are thrown by the library
89
00:03:54,300 --> 00:03:57,403
which don't crash the whole application necessarily.
90
00:03:58,240 --> 00:04:01,173
And here we see that we got a warning actually.
91
00:04:02,010 --> 00:04:05,570
And we get that warning already when we add a goal.
92
00:04:05,570 --> 00:04:09,130
The warning that I get here is in the end that
93
00:04:09,130 --> 00:04:12,893
React encountered two children with the same key.
94
00:04:13,850 --> 00:04:15,830
So two children with the same key
95
00:04:15,830 --> 00:04:18,433
were found here with the key goal1.
96
00:04:19,410 --> 00:04:24,310
And this is implicitly related to our deletion problem.
97
00:04:24,310 --> 00:04:25,650
Now, again, we're not getting that
98
00:04:25,650 --> 00:04:27,130
warning when I delete something.
99
00:04:27,130 --> 00:04:30,640
We already get that warning when I add a new goal.
100
00:04:30,640 --> 00:04:32,020
But this already tells us that
101
00:04:32,020 --> 00:04:34,630
we have some error in our code.
102
00:04:34,630 --> 00:04:37,600
Because if we got two children with the same ID,
103
00:04:37,600 --> 00:04:39,120
with the same key in the end,
104
00:04:39,120 --> 00:04:42,500
then we seem to have an error in our code
105
00:04:42,500 --> 00:04:44,780
where we assigned the same ID multiple times,
106
00:04:44,780 --> 00:04:47,280
which indeed is the problem we have.
107
00:04:47,280 --> 00:04:48,870
And React of course also tells you
108
00:04:48,870 --> 00:04:50,760
where the problem occurs.
109
00:04:50,760 --> 00:04:53,690
This here is an error related to our list
110
00:04:53,690 --> 00:04:55,900
because that key concept as learned
111
00:04:55,900 --> 00:05:00,010
in the lists and conditional module is related to lists.
112
00:05:00,010 --> 00:05:01,930
But it is related to the list here
113
00:05:01,930 --> 00:05:03,203
in the unordered list in the
114
00:05:03,203 --> 00:05:07,010
core skill list component, line eight.
115
00:05:07,010 --> 00:05:09,370
So again, you get a pretty clear idea
116
00:05:09,370 --> 00:05:12,870
of where this warning in this case is coming from,
117
00:05:12,870 --> 00:05:15,010
and you can then have a look at the code there
118
00:05:15,010 --> 00:05:18,050
and find out why that problem occurs.
119
00:05:18,050 --> 00:05:19,870
And if you then work your way back
120
00:05:19,870 --> 00:05:21,910
to the place where goals are added
121
00:05:21,910 --> 00:05:24,090
which is the place where the IDs are added
122
00:05:24,090 --> 00:05:27,590
which in turn are the things that are used as keys here
123
00:05:27,590 --> 00:05:29,760
we do use the goal ID as a key.
124
00:05:29,760 --> 00:05:31,990
Well then you would be able to come back
125
00:05:31,990 --> 00:05:36,300
to the place where the hard-coded goal1 ID is.
126
00:05:36,300 --> 00:05:37,930
Because we even see that goal1
127
00:05:37,930 --> 00:05:40,130
is the problem here in the warning.
128
00:05:40,130 --> 00:05:41,460
So that's another way how you
129
00:05:41,460 --> 00:05:43,940
might've solved this problem.
130
00:05:43,940 --> 00:05:47,180
But you can also use another approach.
131
00:05:47,180 --> 00:05:50,250
You can use the debugger built into the browser.
132
00:05:50,250 --> 00:05:51,833
You can use break points.
9949
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.