Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,200 --> 00:00:04,333
Maximilian: Now, that's it for this section.
2
00:00:04,333 --> 00:00:08,633
In the last section, we again implemented two way binding
3
00:00:08,633 --> 00:00:10,800
as part of the assignment.
4
00:00:10,800 --> 00:00:13,033
Actually it was a bonus section
5
00:00:13,033 --> 00:00:13,933
of the assignment I would say,
6
00:00:13,933 --> 00:00:16,400
but again, we added two way binding
7
00:00:16,400 --> 00:00:19,866
and we did something which has an official term in React
8
00:00:19,866 --> 00:00:22,600
which I don't wanna hide from you.
9
00:00:22,600 --> 00:00:25,533
We created a controlled component
10
00:00:25,533 --> 00:00:25,833
We created a controlled component
11
00:00:25,833 --> 00:00:28,433
and it's not the first time we did that.
12
00:00:28,433 --> 00:00:31,466
Basically, whenever you use two way binding
13
00:00:31,466 --> 00:00:33,700
you are controlling a component
14
00:00:33,700 --> 00:00:37,200
but here we're controlling our own custom component.
15
00:00:37,200 --> 00:00:38,866
Now, what does this mean?
16
00:00:38,866 --> 00:00:42,733
It means that a value which is used in the component
17
00:00:42,733 --> 00:00:45,633
like the value selected in the dropdown
18
00:00:45,633 --> 00:00:45,666
like the value selected in the dropdown
19
00:00:45,666 --> 00:00:50,833
is passed on to a parent component, through props
20
00:00:50,833 --> 00:00:54,700
and is received from the parent component.
21
00:00:54,700 --> 00:00:57,166
Both the currently set value,
22
00:00:57,166 --> 00:00:59,966
as well as the function which in the end
23
00:00:59,966 --> 00:01:02,433
handles the selected value is not part of expenses filter.
24
00:01:02,433 --> 00:01:05,566
handles the selected value is not part of expenses filter.
25
00:01:05,566 --> 00:01:05,800
handles the selected value is not part of expenses filter.
26
00:01:05,800 --> 00:01:08,833
Expenses filter is really just a component
27
00:01:08,833 --> 00:01:12,966
that presents DUI, that presents the dropdown
28
00:01:12,966 --> 00:01:17,166
and then attaches a couple of listeners or props,
29
00:01:17,166 --> 00:01:17,600
and then attaches a couple of listeners or props,
30
00:01:17,600 --> 00:01:21,533
but the real logic recites in the parent component
31
00:01:21,533 --> 00:01:23,966
and that turns ExpensesFilter
32
00:01:23,966 --> 00:01:28,866
into something which is called a controlled component.
33
00:01:28,866 --> 00:01:31,766
Now, technically there is no difference.
34
00:01:31,766 --> 00:01:34,700
ExpensesFilter is still a regular component
35
00:01:34,700 --> 00:01:36,000
as you learned it.
36
00:01:36,000 --> 00:01:36,300
as you learned it.
37
00:01:36,300 --> 00:01:39,233
It's just a special term that when you see it
38
00:01:39,233 --> 00:01:41,500
basically means what I just explained
39
00:01:41,500 --> 00:01:45,066
that both the value, as well as changes to the value
40
00:01:45,066 --> 00:01:47,766
are not handled in the component itself
41
00:01:47,766 --> 00:01:50,233
but in a parent component.
42
00:01:50,233 --> 00:01:50,566
but in a parent component.
43
00:01:50,566 --> 00:01:55,100
This component controls the expenses filter component.
44
00:01:55,100 --> 00:01:58,666
And that's just a term which you should be aware of.
45
00:01:58,666 --> 00:01:59,133
And that's just a term which you should be aware of.
46
00:01:59,133 --> 00:02:02,966
Another term or another concept you should be aware of
47
00:02:02,966 --> 00:02:05,166
because you might hear it from time to time
48
00:02:05,166 --> 00:02:10,366
is about presentational verses stateful components
49
00:02:10,366 --> 00:02:13,766
or stateless versus stateful components
50
00:02:13,766 --> 00:02:13,966
or stateless versus stateful components
51
00:02:13,966 --> 00:02:17,866
or dumb versus smart components.
52
00:02:17,866 --> 00:02:18,000
or dumb versus smart components.
53
00:02:18,000 --> 00:02:22,233
There are a lot of terms for that, but what do they mean?
54
00:02:22,233 --> 00:02:24,833
It simply means that in basically all
55
00:02:24,833 --> 00:02:27,000
React apps which you're building,
56
00:02:27,000 --> 00:02:31,500
you will have a couple of components that manage some state
57
00:02:31,500 --> 00:02:31,766
you will have a couple of components that manage some state
58
00:02:31,766 --> 00:02:33,466
like this expenses component
59
00:02:33,466 --> 00:02:36,166
which manages this filter state
60
00:02:36,166 --> 00:02:41,200
or the expense form component which manages the input state.
61
00:02:41,200 --> 00:02:41,733
or the expense form component which manages the input state.
62
00:02:41,733 --> 00:02:43,900
And then you will have other components
63
00:02:43,900 --> 00:02:48,033
which don't manage any state, like expense item
64
00:02:48,033 --> 00:02:48,133
which don't manage any state, like expense item
65
00:02:48,133 --> 00:02:50,400
if we remove the button, which we should do
66
00:02:50,400 --> 00:02:53,400
because it was just there for demo purposes.
67
00:02:53,400 --> 00:02:57,366
If we remove it, we can also remove the useState call
68
00:02:57,366 --> 00:02:59,566
and we should remove it.
69
00:02:59,566 --> 00:03:00,000
and we should remove it.
70
00:03:00,000 --> 00:03:05,666
We can also remove that and that and if we do all of that,
71
00:03:05,666 --> 00:03:09,166
and we set this here back to props title,
72
00:03:09,166 --> 00:03:13,466
then this is a state less component as it should be.
73
00:03:13,466 --> 00:03:13,800
then this is a state less component as it should be.
74
00:03:13,800 --> 00:03:16,600
This component is a state less component
75
00:03:16,600 --> 00:03:20,833
also called presentational or dumb component
76
00:03:20,833 --> 00:03:23,266
because it doesn't have any internal state
77
00:03:23,266 --> 00:03:27,233
it's just there to output some data.
78
00:03:27,233 --> 00:03:29,633
And in most react applications,
79
00:03:29,633 --> 00:03:34,200
you will have more presentational and dumb components
80
00:03:34,200 --> 00:03:37,466
than smart or stateful components.
81
00:03:37,466 --> 00:03:37,666
than smart or stateful components.
82
00:03:37,666 --> 00:03:40,766
So even though dumb might sound negative
83
00:03:40,766 --> 00:03:44,633
and it might sound like stateful components are better,
84
00:03:44,633 --> 00:03:46,133
that's not the case.
85
00:03:46,133 --> 00:03:46,433
that's not the case.
86
00:03:46,433 --> 00:03:48,300
These are really just terms
87
00:03:48,300 --> 00:03:52,866
and typically you end up with less state full components
88
00:03:52,866 --> 00:03:56,100
than with state less components.
89
00:03:56,100 --> 00:03:56,533
than with state less components.
90
00:03:56,533 --> 00:03:58,900
Because you wanna split up your application
91
00:03:58,900 --> 00:04:01,333
into small reusable pieces
92
00:04:01,333 --> 00:04:04,200
and most pieces, most components
93
00:04:04,200 --> 00:04:07,566
indeed will only focus on outputting something,
94
00:04:07,566 --> 00:04:07,633
indeed will only focus on outputting something,
95
00:04:07,633 --> 00:04:09,566
on having some JSX code,
96
00:04:09,566 --> 00:04:12,333
maybe some transformation logic like this here
97
00:04:12,333 --> 00:04:14,633
and maybe some CSS code,
98
00:04:14,633 --> 00:04:16,800
but it's only a couple of components
99
00:04:16,800 --> 00:04:19,533
which typically do manage state.
100
00:04:19,533 --> 00:04:19,666
which typically do manage state.
101
00:04:19,666 --> 00:04:22,433
And then this state is spread out
102
00:04:22,433 --> 00:04:26,400
and distributed through props in the end,
103
00:04:26,400 --> 00:04:28,800
like here in the expenses component
104
00:04:28,800 --> 00:04:31,600
where we managed to filter state
105
00:04:31,600 --> 00:04:34,400
and then we pass the filtered year.
106
00:04:34,400 --> 00:04:40,066
So this state value through props, back to expenses filter.
107
00:04:40,066 --> 00:04:40,300
So this state value through props, back to expenses filter.
108
00:04:40,300 --> 00:04:43,533
This is a standard pattern which you'll see a lot
109
00:04:43,533 --> 00:04:46,233
that you manage state and a couple of components,
110
00:04:46,233 --> 00:04:50,766
and then you might pass that around to other components.
111
00:04:50,766 --> 00:04:53,566
And that's basically it for this module.
112
00:04:53,566 --> 00:04:57,166
What you learned here again, was super important.
113
00:04:57,166 --> 00:04:59,200
So make sure it's clear to you,
114
00:04:59,200 --> 00:05:01,566
make sure you understand what state is
115
00:05:01,566 --> 00:05:05,500
and how you can handle events and how you can pass data
116
00:05:05,500 --> 00:05:08,000
from a child to a parent component.
117
00:05:08,000 --> 00:05:09,433
And with all of that,
118
00:05:09,433 --> 00:05:12,100
combined with the core section before
119
00:05:12,100 --> 00:05:14,866
we are recovered components in general,
120
00:05:14,866 --> 00:05:18,800
we're now prepared to dive into the next core section
121
00:05:18,800 --> 00:05:24,766
and basically conclude the hard core of React basics.
122
00:05:24,766 --> 00:05:27,566
But the next section again will be super important
123
00:05:27,566 --> 00:05:31,166
because it will be about Lists and Conditional Content.
9892
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.