text
stringlengths 1
81
| start
float64 0
10.1k
| duration
float64 0
24.9
|
|---|---|---|
And this render method goes ahead
and just renders a blank div
| 3,962.79
| 3.33
|
with a blank UL.
| 3,966.12
| 1.285
|
Yeah?
| 3,967.405
| 0.499
|
AUDIENCE: In the previous
version of render,
| 3,967.904
| 1.868
|
why was it returning a [INAUDIBLE]?
| 3,969.772
| 3.597
|
JORDAN HAYASHI: Oh.
| 3,973.369
| 0.791
|
So the question was in my
example to do app three,
| 3,974.16
| 7.71
|
why was render up here returning false?
| 3,981.87
| 4.23
|
So we'll talk about handling
events in a little bit.
| 3,986.1
| 4.24
|
But basically, browsers actually
all have a way to handle events.
| 3,990.34
| 4.49
|
And so if you do something
like click a Submit button,
| 3,994.83
| 2.49
|
it will automatically go ahead
and submit a form for you
| 3,997.32
| 3.57
|
and refresh the page.
| 4,000.89
| 1.78
|
And so a lot of times, when we actually
want to handle that all in JavaScript,
| 4,002.67
| 3.8
|
we have to have a way to disable
the automatic page refresh.
| 4,006.47
| 3.394
|
And so there are a couple
different ways to do that.
| 4,009.864
| 2.166
|
You can do something like event
dot stop propagation or event dot--
| 4,012.03
| 3.285
|
I forget the exact method
name, but it's something
| 4,018.637
| 2.083
|
like stop this event from happening.
| 4,020.72
| 1.71
|
Prevent default. Event
dot prevent default.
| 4,022.43
| 2.36
|
And a shorthand for doing
both of those is just
| 4,024.79
| 2.02
|
returning false out of
whatever handler they do.
| 4,026.81
| 2.94
|
And so when I do return
false from this render, that
| 4,029.75
| 3.687
|
means if I ever want
to do something, like I
| 4,033.437
| 1.833
|
add to do, and hook it up to a button
that might automatically submit a form,
| 4,035.27
| 4.77
|
I can return false from that
instead and automatically
| 4,040.04
| 3.3
|
prevent that from happening.
| 4,043.34
| 1.69
|
And so this is just some shorthand
for rather than having submit buttons
| 4,045.03
| 5.15
|
automatically refresh a
page, it just blocks that
| 4,050.18
| 3.21
|
and lets me handle it all in JavaScript.
| 4,053.39
| 2.132
|
Cool.
| 4,061.295
| 0.5
|
So back to this example in React.
| 4,061.795
| 3.775
|
So we're up to this point where
we have a class called app.
| 4,065.57
| 3.66
|
Right now, we have no state associated
with it, and all we're doing
| 4,069.23
| 3.15
|
is rendering this empty list.
| 4,072.38
| 1.84
|
And so how might we go about
implementing these features
| 4,074.22
| 2.9
|
that we have in our to do project?
| 4,077.12
| 3.141
|
Well, first, we're going to
want to start tracking something
| 4,080.261
| 2.499
|
in [? our ?] state, right?
| 4,082.76
| 1.083
|
Maybe we want to track the to dos.
| 4,083.843
| 3.697
|
And so how do we go ahead and
create something called state?
| 4,087.54
| 3.7
|
Well, first, we want to
invoke the constructor, which
| 4,091.24
| 3.61
|
for now takes no arguments, since we're
not actually passing any props to app.
| 4,094.85
| 4.83
|
First thing we do in the
constructor is always
| 4,099.68
| 2.07
|
called the super, which is invoking
the constructor on React.Component,
| 4,101.75
| 6.09
|
which gives us things
like this dot set state.
| 4,107.84
| 2.519
|
And then now we have the
opportunity to initialize our state,
| 4,110.359
| 3.271
|
so we can go ahead and do
this.state equals whatever.
| 4,113.63
| 5.16
|
And so what might we
want to store in state?
| 4,118.79
| 2.071
|
AUDIENCE: To do list.
| 4,120.861
| 1.398
|
JORDAN HAYASHI: Yeah, the to do list.
| 4,122.259
| 1.541
|
Is there anything else
that we should store?
| 4,123.8
| 1.833
|
Nothing I can think of
off the top of the head.
| 4,127.87
| 2.581
|
But thankfully, if we want to add
something later, it's very easy to do.
| 4,130.451
| 2.999
|
And so let's just do to dos, and
let's store this all on an empty list.
| 4,133.45
| 6.9
|
Cool.
| 4,140.35
| 0.5
|
So now we have this concept of state.
| 4,140.85
| 2.41
|
We now have this concept of to
dos, which is stored in our state,
| 4,143.26
| 3.059
|
but we're not doing anything with it.
| 4,146.319
| 1.87
|
And so let's actually render
those to dos to the screen.
| 4,148.189
| 3.321
|
So we might want to do it
within the unordered list.
| 4,151.51
| 3.36
|
Let's have something like
this dot state dot to dos.
| 4,154.87
| 3.42
|
And again, we wrap things
in single curly braces
| 4,158.29
| 3.189
|
when we want to execute
them as JavaScript.
| 4,161.479
| 2.5
|
And so we have this dot state dot
to dos, which is an empty array.
| 4,163.979
| 3.791
|
But we can't just take for granted
that it's always an empty array.
| 4,167.77
| 3.36
|
The point of writing declarative code
is that we want this to hold true,
| 4,171.13
| 4.14
|
no matter what the state is.
| 4,175.27
| 2.07
|
And so we just assume that this is
full of to dos, and so we can go ahead
| 4,177.34
| 3.479
|
and map over that and render each to do.
| 4,180.819
| 2.011
|
So for each to do, let's
actually create a to do.
| 4,186.52
| 2.85
|
All right, so I'm mapping out
the to dos, and for each to do,
| 4,198.18
| 3.24
|
I'm creating this tag
called uppercase to do.
| 4,201.42
| 4.29
|
So who remembers what
uppercase tags mean?
| 4,205.71
| 5.26
|
AUDIENCE: It's a React component.
| 4,210.97
| 1.79
|
JORDAN HAYASHI: Yeah,
it's a React component.
| 4,212.76
| 2.79
|
And we now have to describe something
called a React component called capital
| 4,215.55
| 4.14
|
to do.
| 4,219.69
| 0.69
|
And so let's go ahead and do that.
| 4,220.38
| 1.416
|
And so just like the examples
that I showed you earlier,
| 4,224.1
| 2.72
|
where we abstracted out the
concept of creating a to do,
| 4,226.82
| 2.357
|
we can do that in React as well.
| 4,229.177
| 1.333
|
So let's have this thing called a to do.
| 4,230.51
| 2.36
|
And what it does is it takes some props.
| 4,232.87
| 2.83
|
We can call this variable
whatever we want,
| 4,235.7
| 2.19
|
but the React convention
is to call it props.
| 4,237.89
| 2.057
|
And what are we going to return?
| 4,239.947
| 1.333
|
Well, let's just return an
unordered list, or a list item.
| 4,241.28
| 4.89
|
What might we have in that list item?
| 4,246.17
| 1.56
|
Well, we had an input of type checkbox.
| 4,250.36
| 3.16
|
We had a button that
allowed us to delete.
| 4,256.96
| 3.72
|
And last but not least,
we had some text.
| 4,263.44
| 3.165
|
And what was in that text?
| 4,266.605
| 1.605
|
Well, probably just props, dots--
| 4,268.21
| 2.46
|
we can call it the text for the to do.
| 4,270.67
| 2.37
|
Cool.
| 4,278.581
| 0.499
|
So now we declaratively just said,
hey, every time we want a to do,
| 4,279.08
| 4.006
|
this is what it looks like.
| 4,283.086
| 1.124
|
It's a list item, and
inside it, we have an input.
| 4,284.21
| 2.284
|
It's going to be a checkbox.
| 4,286.494
| 1.166
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.