text
stringlengths 1
81
| start
float64 0
10.1k
| duration
float64 0
24.9
|
|---|---|---|
But we never actually hook
that up for this example.
| 1,655.43
| 4.53
|
So in the TODO component here
we're passing down an onToggle prop
| 1,659.96
| 4.97
|
but we never actually use it up here.
| 1,664.93
| 2.52
|
And so here we should actually
have the switch when we do on--
| 1,667.45
| 7.65
|
what's it called-- on value change.
| 1,675.1
| 3.02
|
And I only know this because
that's what the documentation says.
| 1,678.12
| 4.06
|
And so when that value changed,
I should run props.onToggle,
| 1,682.18
| 6.18
|
which is the name of the
prop that we're passing down
| 1,688.36
| 3.03
|
from this parent component.
| 1,691.39
| 1.95
|
And so now when we
click TODO it updates.
| 1,693.34
| 4.25
|
And as you see right here the unchecked
TODO count still updates as expected.
| 1,697.59
| 5.664
|
And so now if we create a bunch
we can see those numbers changing.
| 1,703.254
| 3.986
|
We can see the checking and
toggling works as expected.
| 1,707.24
| 2.75
|
We see if we delete this
one the TODO count goes down
| 1,709.99
| 2.43
|
but the uncheck count does not
go down since it was checked.
| 1,712.42
| 2.704
|
If we delete something that isn't
checked, both of them go down.
| 1,715.124
| 2.666
|
And so we have the same behavior as
we did in our React Web application.
| 1,717.79
| 5.917
|
Any questions there?
| 1,728.58
| 1.18
|
So we have this being a scroll view.
| 1,735.2
| 2.73
|
But, if you notice, the
scroll view gets cut off early
| 1,737.93
| 2.77
|
and as we add TODOs it grows.
| 1,740.7
| 4.23
|
But if we add a bunch of
TODOs it grows with it.
| 1,744.93
| 11.59
|
But say we actually wanted the scroll
view to reach all the way to the bottom
| 1,756.52
| 6.54
|
no matter how many TODOs were there.
| 1,763.06
| 2.25
|
Does anybody know how we
may go about doing that?
| 1,765.31
| 3.37
|
The hint being that in order
to control layout what we use
| 1,768.68
| 2.687
|
is this thing called Flexbox.
| 1,771.367
| 1.208
|
So by default components
will grow to however big
| 1,775.66
| 4.83
|
they need to be in order
to fit their children.
| 1,780.49
| 3.48
|
But we have a way of saying, hey fill
as much space as you possibly can.
| 1,783.97
| 4.69
|
And the way to do that
is saying flex: 1.
| 1,788.66
| 3.65
|
And so we want the app container
to have a flex value of 1
| 1,792.31
| 3.94
|
so that the app container
fills up all possible space.
| 1,796.25
| 4.4
|
And so we could do something like
app container let's do flex: 1.
| 1,800.65
| 4.59
|
And then maybe for the TODOs,
the scroll view here, maybe we
| 1,805.24
| 5.67
|
want that to fill as well.
| 1,810.91
| 1.97
|
And so we could go
down to the scroll view
| 1,812.88
| 2.74
|
and say the style is
going to be flex: 1.
| 1,815.62
| 5.61
|
But that isn't great design.
| 1,821.23
| 2.61
|
What if we wanted instead to just have
a style called Fill, which will just
| 1,823.84
| 5.43
|
fill whatever space is available.
| 1,829.27
| 2.49
|
And so that would be a
good abstraction to have.
| 1,831.76
| 2.772
|
So here we have a TODO container,
we have an app container,
| 1,834.532
| 2.458
|
and let's actually create this style
called Fill, which we'll just flex: 1.
| 1,836.99
| 4.37
|
And so now we can say hey, we
want this scroll view to fill
| 1,845.8
| 9.34
|
and we also want our
app container to fill.
| 1,855.14
| 5.37
|
But instead of adding
that to app container,
| 1,860.51
| 3.23
|
what would be a better way to do it?
| 1,863.74
| 1.78
|
Well, we can actually
apply both those styles.
| 1,865.52
| 1.98
|
Does anybody remember how we could
do that, apply multiple styles
| 1,867.5
| 3.09
|
to the same component?
| 1,870.59
| 1.666
|
So in React Web we would actually
just give it multiple classes.
| 1,875.68
| 4.49
|
What is the analog in React Native?
| 1,880.17
| 1.64
|
We can actually just pass an array.
| 1,884.88
| 2.18
|
And so say first apply
styles.Appcontainer and then apply
| 1,887.06
| 3.58
|
styles.fill.
| 1,890.64
| 0.75
|
And now, if we add a
bunch of TODOs we can
| 1,894.63
| 4.23
|
see that it fills the available space.
| 1,898.86
| 2.4
|
And then if we delete TODOs such that
it doesn't fill the available space
| 1,901.26
| 3.96
|
we see that it's not getting
cut off at the bottom
| 1,905.22
| 3.06
|
because it's filling all the way
down to the bottom of this container.
| 1,908.28
| 5.64
|
So any questions on event
handling, styling or moving
| 1,913.92
| 4.92
|
React Web to React Native components?
| 1,918.84
| 2.355
|
No.
| 1,923.925
| 1.301
|
So we've been talking about
this thing called components,
| 1,925.226
| 2.374
|
but we haven't really dived too
deeply into what that really means.
| 1,927.6
| 4.5
|
In the past few weeks, we've
talked about how components
| 1,932.1
| 2.61
|
return a node, how they
represent a discrete piece of UI,
| 1,934.71
| 3.08
|
how all components should act like pure
functions with respect to their props.
| 1,937.79
| 4.01
|
But that's really where we
stopped talking about components.
| 1,941.8
| 2.69
|
And so this week, we're going to
dive more deeply into components
| 1,944.49
| 2.73
|
and what components actually are.
| 1,947.22
| 2.797
|
And so there are actually
two types of components.
| 1,950.017
| 2.083
|
And we've actually seen
both of them already.
| 1,952.1
| 2.05
|
So first is this thing called a
stateless functional component.
| 1,954.15
| 2.92
|
You might see it abbreviated as SFC or
if you're reading blog posts online,
| 1,957.07
| 3.38
|
some people call them pure
functional components.
| 1,960.45
| 2.95
|
And what those are
basically just functions.
| 1,963.4
| 3.65
|
So something like this
TODO that we've created
| 1,967.05
| 3.06
|
is just a function that takes
in props and returns some node.
| 1,970.11
| 3.72
|
It has no concept of state.
| 1,973.83
| 2.676
|
And so that's why it's called a
stateless functional component.
| 1,976.506
| 2.624
|
It's just a function with no state.
| 1,979.13
| 2.41
|
And the second is a
react.component which
| 1,984.09
| 1.86
|
we've been extending from but we
haven't really talked about it
| 1,985.95
| 3.21
|
too far in depth.
| 1,989.16
| 1.91
|
And so first let's talk about
stateless functional components.
| 1,991.07
| 3.041
|
So this is the simplest
type of component.
| 1,999.03
| 2.21
|
You should use this when
you don't need any state.
| 2,001.24
| 3.24
|
And what it is is a function that
takes props and returns a node.
| 2,004.48
| 4.04
|
And it shouldn't do anything other
than taking props and return a node.
| 2,008.52
| 3.34
|
It should be what's
called a pure function.
| 2,011.86
| 1.999
|
In other words, it should not have
any side effects, like setting a value
| 2,013.859
| 3.041
|
or pushing to an array, updating
an object, something like that
| 2,016.9
| 4.86
|
because it should just take
in props and return the value.
| 2,021.76
| 4.2
|
If you do stuff other than that you
might create some bugs or even worse
| 2,025.96
| 5.4
|
crash your app or something like that.
| 2,031.36
| 3.264
|
Then, any changes to the
props that you passed
| 2,034.624
| 1.916
|
to a stateless functional
component will automatically
| 2,036.54
| 2.68
|
cause that function to be re-invoked.
| 2,039.22
| 2.65
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.