text
stringlengths 1
81
| start
float64 0
10.1k
| duration
float64 0
24.9
|
|---|---|---|
And so we might do the
exact same thing with neck.
| 1,107.58
| 3.11
|
And maybe we want to add
something like 19 frets.
| 1,126.46
| 2.775
|
And you can see how this gets a little
bit annoying to write it, right?
| 1,133.67
| 4.65
|
And maybe we do the
same thing with body,
| 1,138.32
| 2.61
|
but we have some sort of for
each loop with the strings,
| 1,140.93
| 9.39
|
and we pass in the tone that we want.
| 1,150.32
| 3.881
|
And then we go ahead and create a
string and tune it to that tone.
| 1,154.201
| 2.749
|
And then we go ahead and
add that to the body.
| 1,165.604
| 1.916
|
And you see how this gets very
step-by-step, exactly what we
| 1,177.93
| 4.371
|
want to do to create a guitar.
| 1,182.301
| 1.249
|
And this is exactly what we've been
doing thus far for writing to the DOM.
| 1,188.19
| 4.11
|
And so how might we do this
in a more declarative manner?
| 1,195.265
| 2.375
|
Well, we would just
say, give me a guitar.
| 1,201.38
| 3.995
|
Give me a string.
| 1,208.58
| 1.57
|
Maybe I want it to be tuned to
the first note in the string.
| 1,210.15
| 7.43
|
And maybe copy that a few times.
| 1,221.382
| 1.333
|
And there we go.
| 1,229.04
| 2.4
|
A better way to do this would be
rather than hard coding these,
| 1,231.44
| 3.57
|
maybe we just do strings.map, and
for each note, we stick it in there.
| 1,235.01
| 11.47
|
So it looks like there's
a little bug here.
| 1,249.559
| 1.791
|
I used string even though I declared
the variable called strings.
| 1,251.35
| 5.97
|
So if we map over the
array called strings,
| 1,257.32
| 2.73
|
and for each note return a
string where the note is note,
| 1,260.05
| 3.45
|
then we have declaratively
written a guitar.
| 1,263.5
| 3.386
|
Does this make sense?
| 1,266.886
| 0.874
|
So a great thing about react
is that the way that you code
| 1,275.58
| 2.76
|
is in a very, very declarative manner.
| 1,278.34
| 3.9
|
The browser APIs aren't
super fun to work with.
| 1,282.24
| 2.43
|
You get to work with them a bit
in project zero, but react just
| 1,284.67
| 3.96
|
allows us to write exactly what we want.
| 1,288.63
| 1.68
|
And the library will actually take
care of the DOM manipulation for us.
| 1,290.31
| 3.92
|
And so what does that really look like?
| 1,294.23
| 1.75
|
So say we wanted to create a slide here.
| 1,303.97
| 3.825
|
Say we wanted to use the
native DOM manipulation
| 1,307.795
| 4.685
|
API in order to create the slide here.
| 1,312.48
| 2.41
|
So we might have a slide
element that we created
| 1,314.89
| 3.14
|
and say we wanted to add a H1 to that.
| 1,318.03
| 2.66
|
Add a title to it.
| 1,320.69
| 0.76
|
How might we do it?
| 1,321.45
| 1.26
|
Well, we'd have to do something like
const title = document.createElement.
| 1,322.71
| 4.514
|
Get an H1.
| 1,331.18
| 2.43
|
And then start adding to that.
| 1,333.61
| 1.25
|
We can do title.innerHTML
is equal to the SLIDE.title.
| 1,334.86
| 5.23
|
And you see how this starts getting
to like what we've been doing earlier,
| 1,344.19
| 3.36
|
where you say exactly what you want,
but it might take you a long time to do.
| 1,347.55
| 5.501
|
So in react land, this
is actually a lot easier.
| 1,353.051
| 1.999
|
So how might we do this if we were
doing this completely declaratively?
| 1,358.84
| 4.4
|
Well, we just say exactly what we want.
| 1,363.24
| 7.57
|
We want a slide.
| 1,370.81
| 2.09
|
Maybe it has a title, where the
title is equal to the slide's title.
| 1,372.9
| 5.565
|
Maybe we have some bullets.
| 1,381.27
| 2.619
|
Or we can just map through the
bullets that we have up there.
| 1,383.889
| 2.541
|
We can do SLIDE.bullets.map.
| 1,386.43
| 2.01
|
And we can say for every bullet,
just give me a list item.
| 1,392.41
| 5.75
|
And maybe we should wrap those
list items in unordered list.
| 1,409.451
| 2.499
|
And maybe instead of using
this, we can do an H1 here.
| 1,416.17
| 2.25
|
So see how this is a
lot more declarative?
| 1,431.07
| 2.32
|
Makes sense, right?
| 1,441.73
| 1.17
|
It just makes sense.
| 1,442.9
| 1.51
|
It's easier to read, and
it's easier to maintain.
| 1,444.41
| 3.02
|
So another great thing about react
is it's very easily componentized.
| 1,450.552
| 4.475
|
What do I mean by componentized?
| 1,455.027
| 1.333
|
Well, it's a process by which you break
a very complex problem into a bunch
| 1,456.36
| 3.48
|
of different, discrete components.
| 1,459.84
| 2.746
|
You can reuse these components,
which is great for consistency.
| 1,462.586
| 2.624
|
So say you had a bunch
of slides, and you wanted
| 1,465.21
| 2.31
|
to just change how every title looked.
| 1,467.52
| 2.735
|
Well, if you did this using
native DOM manipulation,
| 1,470.255
| 2.995
|
that might be a bunch of different
lines of code that you have to change.
| 1,473.25
| 3.41
|
But if you did this
using React components,
| 1,476.66
| 2.787
|
it might just be one line
that you have to change,
| 1,479.447
| 2.083
|
and then it's applied to every
single slide that you have.
| 1,481.53
| 2.922
|
It's also great for iteration
speed, because then you
| 1,484.452
| 2.208
|
can just reuse the
components over and over,
| 1,486.66
| 1.833
|
rather than having to cut and
paste code all over the place.
| 1,488.493
| 3.438
|
Another great thing
about these components
| 1,491.931
| 1.749
|
is that React's declarative nature makes
it very easy to customize components.
| 1,493.68
| 4.74
|
So say we had the last three slides
and wanted to write them in HTML.
| 1,498.42
| 3.61
|
It might look like
something like this, where
| 1,505.065
| 1.875
|
you have a div, which represents
a slide where the titles react.
| 1,506.94
| 5.72
|
You notice these are the same
three bullets as previously.
| 1,512.66
| 2.8
|
We have the declarative slide, where
we have the same bullets as previously.
| 1,515.46
| 5.015
|
And say we wanted to change this.
| 1,520.475
| 1.375
|
Say we wanted to make all of the
titles have a slightly different style.
| 1,521.85
| 5.28
|
Well, how might we do that?
| 1,527.13
| 1.71
|
Well, we'd have to edit this line.
| 1,528.84
| 1.77
|
We'd have to go edit this line.
| 1,530.61
| 1.86
|
Maybe down there, there's another
title that we have to change.
| 1,532.47
| 2.73
|
Or what if we wanted to even change the
structure of how we represent bullets?
| 1,535.2
| 4.47
|
Maybe rather than using
an unordered list,
| 1,539.67
| 2.72
|
we might use an unordered list with
a div that wraps the list items.
| 1,542.39
| 4.43
|
Well, in order to do that, that would
be a lot of code you have to change.
| 1,546.82
| 3.83
|
But imagine that we had broken this up
into a bunch of different components.
| 1,550.65
| 3.66
|
Where might it make
sense to break it up?
| 1,554.31
| 2.99
|
Well, you see us repeating code
that looks pretty much the same
| 1,557.3
| 4.042
|
over here, right?
| 1,561.342
| 0.708
|
So maybe that should be broken
up into a separate component.
| 1,562.05
| 3.3
|
So how might we go about doing that?
| 1,565.35
| 1.65
|
Well, first we have to extract the
information, and so in this array here,
| 1,571.05
| 4.61
|
we have the slides where
I've basically just ripped
| 1,575.66
| 3.27
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.