text
stringlengths 1
81
| start
float64 0
10.1k
| duration
float64 0
24.9
|
|---|---|---|
So all of the React Native components,
the React components sorry,
| 875.58
| 3.88
|
we've changed to React Native
components and now we have--
| 879.46
| 3.388
|
Oops, something's breaking still.
| 882.848
| 2.322
|
Prompt is another one
of those browser APIs
| 890.42
| 3.9
|
that just does not exist in
the React Native world which
| 894.32
| 2.7
|
caused our code to crash.
| 897.02
| 1.39
|
And so rather than using
one of these browser
| 898.41
| 2.96
|
APIs let's just replace it with
some hard coded text for now,
| 901.37
| 3.21
|
maybe something like to do, number,
and then whatever it's ID is.
| 904.58
| 8.15
|
And rather than
incrementing ID down there
| 916.511
| 1.749
|
let's actually increment it up here.
| 918.26
| 1.5
|
And so now it works.
| 922.51
| 1.15
|
So we have to do number
one, to do number two
| 923.66
| 2.42
|
and you can see how we add those.
| 926.08
| 3.31
|
And so we'll fix the
style in the future,
| 929.39
| 2.1
|
but basically does
anybody have questions
| 931.49
| 2.64
|
on going from React Web to React Native?
| 934.13
| 3.39
|
What we did there was just replace
all the React Web components
| 937.52
| 3.36
|
with the React Native components.
| 940.88
| 1.89
|
And it is almost as easy as command
effing and replacing like that.
| 942.77
| 4.52
|
Great.
| 951.291
| 0.499
|
And so how are you going to go
about styling those components?
| 951.79
| 3.27
|
So in React Web the way
we did that was just
| 955.06
| 2.9
|
by adding a class name and then
styling in CSS, but in React Native
| 957.96
| 3.89
|
we don't have this concept of CSS.
| 961.85
| 3.492
|
So the way that React
Native handles that
| 965.342
| 1.708
|
is by actually using JavaScript objects
for styling and what that gives us
| 967.05
| 3.33
|
is the ability to use dynamic styles.
| 970.38
| 4.11
|
Object keys in these objects
are based on CSS properties,
| 974.49
| 3.35
|
so we have stuff like margin top,
margin bottom, margin padding.
| 977.84
| 5.726
|
And the layout system
that we used is Flexbox
| 983.566
| 1.874
|
and so, if you're familiar
with the Flexbox system in web,
| 985.44
| 2.416
|
it's almost exactly the
same in React Native.
| 987.856
| 3.104
|
One of the key differences
is that rather than
| 990.96
| 3.06
|
defaulting to row we default to
laying out things in columns.
| 994.02
| 7.48
|
So, in React Web, we have this
concept of pixels or percentages,
| 1,001.5
| 3.52
|
but in React Native we actually
use unit-less numbers for length.
| 1,005.02
| 4.36
|
Which is good because there
are so many different devices
| 1,009.38
| 3.48
|
that this runs on with
different pixel densities
| 1,012.86
| 2.19
|
that having a unit-less number allows
us to abstract that pixel density out.
| 1,015.05
| 4.18
|
The style prop, so the way that
you style a given component
| 1,022.52
| 3.72
|
is by assigning that JavaScript
object to a style prop
| 1,026.24
| 3.89
|
and it can actually
take an array of styles.
| 1,030.13
| 1.87
|
And so, if you wanted to have a bunch
of different class names in React Web
| 1,032
| 3.78
|
you'd just start adding those
with a space in between.
| 1,035.78
| 3.6
|
But in React Native you handled
that by passing an array of styles.
| 1,039.38
| 3.075
|
So let's go ahead and add styles
to this app that we have here.
| 1,045.109
| 7.121
|
So first, let's go ahead
and style this view.
| 1,052.23
| 2.24
|
And so right now, as you see, each
to do has a Delete button and a
| 1,054.47
| 6.27
|
to do right under it, whereas in web
we had the Delete button next to that
| 1,060.74
| 4.24
|
to do.
| 1,064.98
| 0.5
|
And so let's try to
figure out exactly how we
| 1,065.48
| 2.32
|
can get that Delete button over
here and the to do to be next to it.
| 1,067.8
| 4.7
|
And so does anybody have any ideas
about how we might want to do that?
| 1,072.5
| 4.59
|
We know we're going to
have to pass a style prop,
| 1,077.09
| 2.43
|
and we know that it's
going to be an object.
| 1,079.52
| 3.45
|
And so this looks weird to
have those double curlies
| 1,082.97
| 2.46
|
but the outer curlies
mean, hey here comes
| 1,085.43
| 2.7
|
some JavaScript and the inner
curlies are just an object
| 1,088.13
| 3.06
|
literal like we've seen before.
| 1,091.19
| 2.88
|
And so how might we get
those to dos to be in a row?
| 1,094.07
| 3.61
|
So we saw before that React Native uses
Flexbox in order to handle it's layout.
| 1,100.35
| 6.81
|
And so we can just say, hey we want
the flex direction, rather than being
| 1,107.16
| 6.63
|
column by default, let's set it to row.
| 1,113.79
| 2.818
|
And so now we have the Delete
button next to the to do.
| 1,119.42
| 5.19
|
But it's annoying me a little bit how
that button is slightly below the text.
| 1,124.61
| 5.77
|
And so how might we get those
items to be aligned to center?
| 1,130.38
| 5.36
|
Well in Flexbox we have this
thing called align items
| 1,135.74
| 6.12
|
and then you just say, hey
align those to be center.
| 1,141.86
| 3.66
|
Then all of a sudden we
have it aligned center.
| 1,145.52
| 2.27
|
And just confirming that
delete button does indeed work.
| 1,151.55
| 3.841
|
Great.
| 1,155.391
| 0.499
|
Anybody notice any other
bad style bugs over here?
| 1,155.89
| 3.45
|
So look at this.
| 1,161.89
| 3.25
|
So most phones will have some
nav bar, and that nav bar
| 1,165.14
| 5.72
|
will have stuff like if you're
connected to Wi-Fi, the time and etc.
| 1,170.86
| 3.87
|
But that first view is actually
going all the way to the top.
| 1,174.73
| 3.95
|
And so how might we get all this
content to be slightly moved down?
| 1,178.68
| 3.46
|
So how would we do that in Web?
| 1,186.29
| 2.75
|
AUDIENCE: Add a margin.
| 1,189.04
| 1.98
|
SPEAKER 1: Yeah we would add a
margin or some padding or something
| 1,191.02
| 2.75
|
to move the content from
the top slightly down.
| 1,193.77
| 4.09
|
And so we could do that
in React Native as well.
| 1,197.86
| 3.68
|
So you can say with this view, let's
actually put a padding on the top
| 1,201.54
| 7.57
|
and let's just say something like
50 which is somewhat arbitrary.
| 1,209.11
| 4.741
|
And now we've gone ahead and
moved that down slightly.
| 1,213.851
| 2.249
|
But what if we wanted to move it down
exactly the same amount as the status
| 1,219.46
| 6.08
|
bar?
| 1,225.54
| 0.5
|
Well there's this great
tool called Expo which
| 1,228.96
| 2.85
|
we'll talk about in length later today.
| 1,231.81
| 1.84
|
They're also the people
who designed Snack.
| 1,233.65
| 2.3
|
And they actually give you
this thing called constant
| 1,235.95
| 2.61
|
so we can do import constants from Expo.
| 1,238.56
| 3.515
|
And we can actually say,
hey padding top rather
| 1,245.56
| 2.2
|
than assigning an arbitrary value of
50 let's do constants.statusbarheight
| 1,247.76
| 8.76
|
and that will actually give you
that exact status bar height
| 1,256.52
| 4.05
|
even if you're on different phones.
| 1,260.57
| 2.174
|
And so, again, we'll
talk about Expo and we'll
| 1,262.744
| 1.916
|
talk about importing and
exporting later today.
| 1,264.66
| 3.17
|
But just FYI there's this thing called
constants.statusbarheight which will
| 1,267.83
| 3.99
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.