text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
And so we're starting to break out something
3,544.19
2.34
that was pretty complicated into now two separate steps, where
3,546.53
3.27
each step is relatively simple.
3,549.8
3.07
But still in each step, we have to go about all of these steps
3,552.87
3.08
in order to get what we want.
3,555.95
5.11
So what might be a better way to do this?
3,561.06
5.03
Well, rather than going through the steps, where we say, oh, hey,
3,566.09
4.59
get me a new element called a list item and input button in a span,
3,570.68
3.6
maybe we wanted just to write that all somewhat declaratively ourselves.
3,574.28
4.03
And so we can actually do something called innerHTML,
3,578.31
3.65
so say we created a list item.
3,581.96
1.65
And maybe we want to take advantage of JavaScript's ability
3,593.35
3.85
to do in-line string concatenation in order
3,597.2
3.99
to create some HTML directly here.
3,601.19
2.89
So we could do something like li.innerHTML,
3,604.08
6.85
and we can start actually putting this directly in here.
3,610.93
3.04
And so this will actually, in a more declarative manner, say,
3,627.31
2.82
hey, I want an input, a button in the span,
3,630.13
2.58
and just stick this in the innerHTML of that list item.
3,632.71
3.87
And so it's starting to look somewhat like something
3,636.58
2.91
we've seen before, right?
3,639.49
1.62
It's starting to represent more of a React component.
3,641.11
5.28
Do you guys see how that is starting to look a lot like what we were
3,646.39
3.93
doing before, using React components?
3,650.32
1.98
But let's stick with vanilla JavaScript still and take this a step further
3,656.62
6.69
and actually store the to dos in memory.
3,663.31
1.88
And so what have we been previously using to store to dos?
3,665.19
3.68
Well, we've just been adding them to the DOM,
3,668.87
3.18
and then using the DOM as a way to remember exactly what our to dos are.
3,672.05
3.76
But what if we actually wanted to rather than storing it on the DOM,
3,675.81
2.96
actually store that in JavaScript, in some sort of data
3,678.77
2.34
structure in our JavaScripted memory?
3,681.11
4.2
Well, that might be easier to do stuff like delete on.
3,685.31
3.7
But how are we going to get that to the DOM?
3,689.01
2.465
Well, we're going to actually have to write a method ourselves.
3,691.475
2.625
And so maybe we have to dos stored in memory as an array.
3,694.1
5.044
Maybe we have something called a render to do,
3,699.144
1.916
which will actually render a single to do.
3,701.06
2.08
And by render, I mean turn that to do, an object in memory,
3,703.14
4.13
into actual HTML, something that the browser can display.
3,707.27
3.816
And so that takes care of rendering a single to do,
3,711.086
2.124
but how are we going to render that entire to do list?
3,713.21
2.249
Well, maybe we want to clear the list and actually map over the to dos.
3,715.459
7.711
So we do to dos dot map.
3,723.17
1.23
What are we mapping?
3,724.4
0.833
Well, let's actually render each of those to dos.
3,725.233
2.537
And for each of the to dos that we rendered,
3,727.77
2.14
go ahead and append that to the list.
3,729.91
3.89
And so now we went from storing to dos in memory,
3,733.8
3.32
creating this concept of rendering, where we turn a single JavaScript
3,737.12
3.99
object into an actual thing that the browser can display.
3,741.11
4.83
And then we have this concept called render, which
3,745.94
2.22
actually renders all of our to dos.
3,748.16
2.85
And so we go from what used to be a very imperative way of writing
3,751.01
2.88
JavaScript, and going from having a single to do to appending that
3,753.89
4.2
to the DOM.
3,758.09
1.12
So now we're a more declarative way.
3,759.21
1.88
We're declaring that a bunch of to dos may exist.
3,761.09
2.94
We're declaring that, hey, here's a way to render a single to do
3,764.03
3.78
and writing a way to turn that list into a full rendered page.
3,767.81
7.654
And so now when we want to add a to do, rather
3,775.464
1.916
than doing a bunch of DOM manipulation, maybe we actually
3,777.38
3.12
want to just do something like a new to do and push that to the list.
3,780.5
5.316
Well, once you push it to the list, now we have to manually say, hey,
3,785.816
2.874
we updated the list.
3,788.69
0.87
Let's go ahead and render that to the page.
3,789.56
3.48
And so now if we're storing everything in memory,
3,793.04
2.4
it becomes a lot easier to remove things.
3,795.44
2.86
And so how are we going to remove the to dos?
3,798.3
2.19
Well, we have to figure out exactly how to do the to dos,
3,800.49
2.374
and this is just an implementation detail.
3,802.864
1.826
But we can actually reset to dos to be a filtered list.
3,804.69
2.67
So just filter them by excluding that to do that we didn't want to be included.
3,807.36
7.65
And then we, again, since we changed everything,
3,815.01
2.21
now we're going to have to go and manually kick off a render.
3,817.22
3
And so now we're writing JavaScript in more of a declarative paradigm, more
3,820.22
3.42
like what we saw in React earlier.
3,823.64
2.52
But we're still implementing stuff like rendering and rendering a single to do
3,826.16
4.8
and kicking off these things manually.
3,830.96
2.61
And let's actually see how this looks if we were all to do it in React,
3,833.57
3.75
where React actually handles a lot of the data rendering to the screen,
3,837.32
4.17
using a library rather than stuff that we have to write manually.
3,841.49
3.06
So let's actually do this from scratch.
3,848.036
2.734
First let me save this.
3,850.77
1.4
So let's go ahead and actually, from scratch, implement our to do list
3,873.79
5.48
all in React.
3,879.27
1.5
So of course, we're going to have to store stuff in state.
3,880.77
2.67
So rather than having app be a function, what might we want to do instead?
3,883.44
4.999
Have it be a class.
3,888.439
0.791
And just like in the example I was showing earlier,
3,895.896
2.124
we have a concept of rendering that app.
3,898.02
2.002
React components actually do this automatically
3,900.022
1.958
for you in this render method.
3,901.98
2.28
And so let's go ahead and implement that rendering method.
3,918.054
2.416
And so returning this.
3,932.98
3.46
And now we have a blank to do list.
3,942.745
7.475
So now we have a class called app.
3,950.22
2.19
It's extending React component, which gives us what?
3,952.41
4.5
It allows us to have state, and it gives us access
3,956.91
2.49
to this thing called this dot set state in order to update the state.
3,959.4
3.39