text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
give us exactly that status bar height. | 1,271.82 | 2.67 |
And now we have a to do app
that doesn't look half bad. | 1,274.49 | 3.14 |
Cool. | 1,277.63 | 0.5 |
So there's actually this
thing called style sheet | 1,278.13 | 2.27 |
which is part of React Native which has
some optimizations for these styles. | 1,280.4 | 5.91 |
And so we talked about earlier how the
way that your JavaScript communicates | 1,286.31 | 4.11 |
with the UI throughout
is through this bridge. | 1,290.42 | 3.65 |
And so that means every single
time you want a view with the style | 1,294.07 | 3.46 |
you need to send those style
attributes over the bridge. | 1,297.53 | 2.7 |
There's actually a way
that you can optimize this. | 1,300.23 | 2.13 |
And so the Facebook team
created this thing called | 1,302.36 | 2.083 |
style sheet which does this for you. | 1,304.443 | 1.967 |
So it's basically the same thing
as creating objects for style, | 1,306.41 | 2.67 |
but as an additional optimization that
rather than sending this style object | 1,309.08 | 5.04 |
over the bridge we can only send IDs. | 1,314.12 | 2.55 |
And so say we have these objects,
rather than passing the full object | 1,316.67 | 6.78 |
every time you can just
say, hey this object, | 1,323.45 | 1.925 |
let's assign it this
arbitrary ID of one. | 1,325.375 | 2.215 |
And so every time we say, hey
this should have a style of one, | 1,327.59 | 4.72 |
the UI thread will know, oh, I
know exactly what style that means. | 1,332.31 | 4.11 |
And so to do that, all we have to do
is import this thing called style sheet | 1,336.42 | 6.26 |
from React Native and we can do this. | 1,342.68 | 1.77 |
And so we're saying we're declaring our
styles as a constant outside of our app | 1,351.83 | 5.42 |
and we're saying, hey
create this style sheet | 1,357.25 | 2.64 |
and we're going to pass into
you an object where the keys map | 1,359.89 | 2.55 |
with how we're going to use this later. | 1,362.44 | 3.676 |
And so we can go ahead
and abstract this out. | 1,366.116 | 1.874 |
And so we can say, this
here we're actually | 1,367.99 | 4.38 |
going to call our to do container. | 1,372.37 | 3.995 |
And our to do container will just say,
all right flex in the row direction | 1,380.085 | 7.165 |
and align your items to be centered. | 1,387.25 | 2.922 |
And then down here
for style we just say, | 1,390.172 | 1.708 |
oh, we want to use styles.todocontainer. | 1,391.88 | 1.73 |
And let's actually lowercase
this for convention. | 1,397.42 | 5.04 |
And as you can see those
styles still get applied. | 1,402.46 | 3.86 |
And why else might this pattern be good? | 1,406.32 | 3.34 |
Does anybody see something
better about this pattern? | 1,409.66 | 2.37 |
AUDIENCE: It's reusable. | 1,415.229 | 1.831 |
SPEAKER 1: Yeah exactly, it's reusable. | 1,417.06 | 3.21 |
And so say we wanted to
have something else that | 1,420.27 | 2.94 |
had very similar styles
to to do container | 1,423.21 | 5.49 |
we can actually use that again. | 1,428.7 | 1.299 |
And then if we wanted to change
both of them at the same time | 1,429.999 | 2.541 |
we could do it by using
this abstracted out object. | 1,432.54 | 2.94 |
And so let's do the app container
and set that equal to this object. | 1,435.48 | 7.66 |
And then down here for this view
let's do styles.appcontainer. | 1,451.27 | 3.75 |
And so there's actually an
even better reason to do this | 1,458.61 | 4.99 |
and it's because every
single time we rendered, | 1,463.6 | 2.29 |
we used to be building a
new style object to pass. | 1,465.89 | 2.87 |
And now we're just using
that same reference | 1,468.76 | 2.13 |
to that object that we created
outside of this component. | 1,470.89 | 3.81 |
And so that's just an additional
optimization that, using this pattern, | 1,474.7 | 4.99 |
creating the styles outside of
the component allows us to do. | 1,479.69 | 3.14 |
Cool. | 1,485.56 | 2.19 |
Any questions on styles and styling? | 1,487.75 | 3.68 |
Great. | 1,491.43 | 0.5 |
So let's talk about event handling. | 1,494.69 | 2.53 |
So unlike Web not every component
has every single interaction. | 1,497.22 | 3.71 |
And so in Web, if we had a div, we
can assign an onClick to that div | 1,500.93 | 3.24 |
or if we add a list item or a list,
anything we can assign an onClick to. | 1,504.17 | 4.23 |
But unlike Web there are only a few
touchable components in React Native | 1,508.4 | 3.48 |
and those are a button,
which we've used before. | 1,511.88 | 3.469 |
These three things called touchable
opacity, touchable highlight | 1,515.349 | 2.666 |
and touchable without
feedback, which are just | 1,518.015 | 4.436 |
three basic components that have
slightly different reactions when | 1,522.451 | 2.749 |
you touch them. | 1,525.2 | 1.292 |
An then lastly, this thing
called touchable native feedback | 1,526.492 | 2.458 |
which is this native component
that you can only use on Android. | 1,528.95 | 4.09 |
And so in Web, when you
had an event handler, | 1,536.33 | 3.36 |
that handler would receive
that event as an argument. | 1,539.69 | 2.87 |
But that's not necessarily true
for all React Native handlers. | 1,542.56 | 5.88 |
And so in order just to
find out how those work | 1,548.44 | 2.57 |
you basically have to
consult the documentation. | 1,551.01 | 2.57 |
The documentation for React
Native is really good. | 1,553.58 | 2.14 |
I recommend that you
peruse them just to see | 1,555.72 | 2.03 |
what components are available
to you and those component APIs. | 1,557.75 | 3.92 |
And basically most of the
stuff that you want to do | 1,561.67 | 3.25 |
is already pre-built for you. | 1,564.92 | 1.742 |
And so, even though
there's no such thing | 1,566.662 | 1.708 |
as a checkbox component in React Native,
there is actually a way to do that. | 1,568.37 | 4.82 |
And so let's go ahead
and add this thing which | 1,573.19 | 2.65 |
is similar to a checkbox
in that it's a Boolean flag | 1,575.84 | 4.47 |
but it's not really exactly
stylistically the same. | 1,580.31 | 3.462 |
And so let's add this
thing called a switch. | 1,583.772 | 1.833 |
As a switch you'll see what
it looks like in a moment | 1,589.082 | 3.428 |
but it's basically just a Boolean flag
that we're going to use in this example | 1,592.51 | 3.487 |
rather than using a checkbox. | 1,595.997 | 1.208 |
So before what we had here was an
input of type checkbox and instead | 1,600.94 | 4.04 |
we're going to use a switch. | 1,604.98 | 2.26 |
And the value of that is going to be
whether the props.TODO is checked. | 1,607.24 | 5.21 |
And so now when we add
a TODO we see the switch | 1,616.7 | 2.4 |
that can be flipped back and forth. | 1,619.1 | 2.41 |
But if you notice, every
time I try to flip it on it | 1,621.51 | 2.81 |
immediately turns back off. | 1,624.32 | 3.15 |
Can anybody spot why that's happening? | 1,627.47 | 2.7 |
So we have this value set to props.TODO
checked, and down here do we ever | 1,634.97 | 7.25 |
update that value? | 1,642.22 | 0.934 |
No we don't. | 1,645.76 | 0.81 |
So we have this thing called Toggle
TODO which we implemented last week, | 1,646.57 | 3.93 |
which, given some TODOs ID will
flip that Boolean checked flag. | 1,650.5 | 4.93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.