📺 Develpreneur YouTube Episode

Video + transcript

React Native Fundamentals Part 10

2021-10-26 •Youtube

Detailed Notes

In this video, we expand on React Navigation with Tab Navigation in React-Native. Specifically how to use Tabs to navigate around our screens instead of using the navigator.

Just in case you missed the last video you can find it here or you need a refresher you can find the first video Started Using React Native For Your Mobile Applications here.

Tab Navigation in React-Native focuses on: Required Dependencies Tabs IonIcons For a full list of components and APIs goto https://reactnative.dev/docs/accessibilityinfo

Tab Navigation

Possibly the most common style of navigation in mobile apps is tab-base navigation. Where the application displays tabs on the bottom of the screen or on the top below the header (or even instead of a header) for navigating between screens. Before we begin we need to install some additional dependencies for npm and expo.

Installation and setup

First, you need to install them in your project:

npm install @react-navigation/native React Tab Navigation is made up of some core utilities we use to create the navigation structures in our apps. These utilities include with @react-navigation/native are:

@react-navigation/bottom-tabs @react-navigation/stack @expo/vector-icons/Ionicons react-native-vector-icons/Ionicons Using the Stack Navigator With Tabs

Usually tabs don't just display one screen; For example, on your Facebook feed, you can tap on a post and it brings you to a new screen within that tab with all of the comments. Another way to think about would be to think of this as being a separate navigation stacks within each tab, and that's exactly how we will model it in React Navigation.

Customizing Tabs

This is similar to how you would customize a stack navigator. While there are some properties that get set when you initialize the tab navigator and others you customize per-screen in the options. One such option is using Ionicons.

Ionicons

Premium designed icons for use in web, iOS, Android, and desktop apps. Support for SVG and web font. Completely open source, MIT licensed and built by the Ionic Framework team.

Additional Resources React - https://reactjs.org/ Node - https://nodejs.org/en/ Visual Studio Code - https://code.visualstudio.com/ Android Development - https://developer.android.com/studio Xcode - https://apps.apple.com/us/app/xcode/id497799835?mt=12

Transcript Text
[Music]
all right so we now have our react
native so we have our components here
so now let's create a home screen for
our application
let's create a custom component so
function
on screen
and we are going to return
a view
we have view component added
so here we're going to add a view
then we're going to add some attributes
to our view
we're going to add some style
and we will add
a screen view
component to our styles in just a second
and inside of our view we're going to
add some text so let's add a text
tag and in here we will just say home
screen just so we can see that we have a
screen loaded
all right and down to our styles here
we'll add
screen view
view
and we're going to add flex
of one
we're going to add a line
item
and we're going to align them to center
and we're going to justify our content
to also be centered
save that
all right next
let's add
our stack so create a constant
we'll call it stack and this is going to
be our navigation stack for windows or
for our screens
and we're going to create
stack navigator
so we'll call the method create stack
navigator
and that creates our stack object
now in order to use the stack object and
actually put our window inside of our
stack
we come down here to our app section
let's get rid of this default view
and now we need to use a new container
our navigation container
and inside our navigation container is
we're going to apply our stack
we're going to call the navigator
module of stack
so we now have our instead of a view
we have a navigation navigation
container which contains a stacked
navigator and inside the stack navigator
we're going to add
our screen
we'll do stacked
dot screen
we're going to give it a properties name
of home
we'll use for referencing this screen
later
and the component we're going to tie it
to
is our home screen
and this is a self-closing tag
so when we save this
we now get our home screen
so we can now see that the code displays
an empty navigation bar
so no navigation bar
and gray content area containing the
home screen text
all right so that's fairly simple so now
let's set up the navigator to handle
another screen
so when dealing with the navigator we
have to configure all the routing using
properties
now in this example we did not set up
any properties because the stack by
default will take the first screen in
the container and use that to render the
first screen
so let's create a second screen here
let's do function
other screen
i'm going to return
another view
we're going to use our style
and we're going to use styles
and we're going to reuse our screen view
and we're going to close our view
oops access view
view
now we want to add some text
and we'll just call this another screen
okay pretty straightforward
and now to add it to the stack so we
come down here
and we copy our stack screen here
we create a new name
to reference our new screen other
and now we need to point to the new
component
we'll do other screen
and if i run this
we see we still only get home screen
however our application now has two
routes
we have a home route and another route
a route can be specified by using the
screen component
the screen component accepts a name
property which corresponds to the name
of the route we will use to navigate and
a component property which corresponds
to the component it will render
in this case the home route corresponds
to the
home screen component and the other wrap
corresponds to the other screen
component
now by default the initial route for the
stack is the home route because it is
the first screen in the stack
however if we change it to other and
reload the app
so let's change the order
so if we swap this around and save this
you'll notice that reacts natives fast
refresh won't update the changes from
the initial route name as you might
expect
instead we have to open up our console
here
and hit r to reload our screen
now we see that we have the other screen
displayed
that's because when the application
loads the first time it loads
this stack
and this does not get reloaded until the
application is closed and reopened or
forcefully reloaded
let's switch this back
save you noticed it in refresh
so we come back out here forcefully
refresh
and now we have our home screen
now there's some additional
options
and parameters you can pass
through your screen
so let's talk about how we can
specifically set the screen options and
passing additional properties
first we can use the stack screen option
attribute
which we can then use to set things like
the page title
as you can see at the top we changed
the title of our screen to home
or we might want to pass some additional
properties to a screen and we can do
this with two approaches
first we can use the react context and
wrap the navigator with a context
provider to pass data to the screens now
this is recommended but outside of the
scope of what we're going to cover here
today
the second approach we can use a
rendered callback for the screen instead
of specifying a component property
and to do that what you do here
is we create
we don't
they'll close the tag but instead we can
wrap the properties
inside of a props here
and then you can define some properties
for your particular screen now again
this is outside the scope of today but i
did want to mention this
so in case you do want to pass
properties or some values between
screens this is one way to do it and
we'll cover that in a future lesson
scroll this back
right so next let's look at moving
between the screens so let's look at how
we can actually navigate between our
home screen and our other
so before we look at how to navigate
between the screens let's review how
this would have worked in a web page
so
one way we can do this from a web page
browser
and let's get back to document stuff
so one way is to actually go to the tag
and call the page directly we can do the
anchor tag href and hard code the value
to our page
another way is to actually wrap an
element
with a onclick function that we could
then use the window.location.href
and then pass in the page name that we
would want to call so we can essentially
use javascript
to call an onclick command to change the
window location to a specified page
now in react native we'll do something
similar to the latter but rather than
using a window.location
global we will use the navigation prop
that is passed down to our screen
component
let's update our dependencies
and already added button we now have
button
which is going to act like our anchor
tag
and next we need to add a navigation
property to our screen
both add navigation
we've added a property to our home
screen
and then in here let's add a button
give it a title
go to other screen
and instead of on click we're going to
do on press
and we're going to do a self-calling
function
and we're going to call the navigation
property that we're going to pass in
dot
navigate
and then we're going to give it the
reference
that we have defined down here so we're
going to use the name other
so that we will call the other
screen
there we go
now it's happy
so now when we look at our screen we now
have home screen and go to other screen
so if we click go to other screen we now
navigate over to other screen and we
have the default navigation bar or
breadcrumb up here that we can use to go
back and forth between the screens
so let's recap so first we use the
navigation prop
which is passed into every screen
component in the stack navigator
then we added the navigate
other here using the navigation so we
called the navigate function in
navigation property and we passed in
the page that we wanted to go to
so this calls the navigate function of
the navigation prop with the name of the
route that we would like to move the
application to
i would like to note though that if we
call navigation.navigate
with a route name that hasn't been
defined yet
it will print an error in the
development build and nothing will
happen in the production build when you
try to run this it'll fail it'll throw a
message
right so now what happens if we keep
navigating to a route multiple times
so let's make a change
to our other screen
let's also add
navigation
and in here let's also add a button
and this time we're going to go to the
other screen again
at least we're going to attempt to
all right so over here in our
application we have our home screen
we'll click our button to go to the
other screen
now we have another button on the other
screen that if we click here
looks like it's clicking but nothing is
happening
so
if you'll notice that when we click the
go over again it doesn't do anything now
that's because we have already uh or
we're already on the other page we're
already on the other route the navigate
function roughly means go to this screen
however if you're already on the screen
then it does nothing
now if we really want the application to
add another other screen to the stack to
the route this is pretty common if we
want to pass in some unique data to each
route
so let's not touch on passing data for
now
instead let's look at how we can make
the application add another on screen to
the stack
now to do this we can change the
navigate here
to push
this allows us to express the intent to
add another route regardless of the
existing navigation history
so now each time we call push we add a
new route to the navigation stack
when you call navigate it first tries to
find an existing route with the name
and only pushes a new route if there
isn't yet one on the stack
however with push it will continue to
push
whatever
component you're trying to add to the
stack regardless if it's already loaded
or not
and now if we click other we can go back
up the navigation till we get back to
the home page
so the header provided by the stack
navigation will automatically include a
back button when it is possible to go
back from the active screen so if i
click go to other screen we have this
back button here of home which will take
us back to the previous screen that was
called from
when there's only one screen in the
navigation stack there is nothing you
can go back to
and so there is no back button or back
navigation
if we really want to rely on the stack
to handle this behavior we can just use
navigation. go back
to trigger this behavior
programmatically
all right so let's look at another
example
so let's add two more buttons to the
other page
these buttons will allow us to return
back to the home screen at the top of
the stack
we can call the nav gate not to push to
reset to the top of the stack
so first let's come down here and add
another button
we'll add a title
of go to home
we'll use the on press
attribute
and we will do a self calling function
and we will call navigate navigation
dot navigate
and we will go to the home page or home
now if i go to the other screen
i have two buttons i have go to other
again
or i have go to home which returns me
back to the top of the stack and it
removes the back button
now if we only want to go back one
screen in the stack without using our
navigation
button at the top of the screen we can
use the navigate function go back
so to add another button here
and we will name it go back
on press again
help calling function called the
navigation
and this time we will call
go
back
now if i go to the other screen i now
have the other screen again go home go
back so if i click go back we go back up
the queue just like if we were hitting
the
navigation button up here
now one thing to note though is on
android the react navigation hooks into
the hardware back button and fires the
go back function for you when the user
presses it
so it behaves as if the user would
expect it to
so again if you're on android and you
hit the go back button it basically
triggers the same functionality it calls
the same go back
function
all right does anyone have any questions
yeah
i mean i've seen you do linux does this
require a lot of linux
no this is all uh
app-based
development
the only
uh the only the only linux piece here
you can actually do on windows 2. but
you have to
kick off
either using node or expo you have to
start
the
emulator essentially for you to run your
native applications on your desktop okay
so it's just a command line it's not
necessarily linux
okay
good question any others
nope
all right so let's review
so react native doesn't have a built-in
api for navigation like a web browser
does
react navigation provides this for you
along with the ios and android gestures
and animations to transition between
screens
we also talked about the stack.navigator
which is a component that takes the
route configuration as its children with
additional props for configuration and
rendering of our content
we can also add multiple screens using
the stack.screen component which takes a
name property which refers to the name
of the route and the component property
which specifies the component to render
for the route
now if we want to
specify what the initial route is
uh in the stack it's provided we can use
a property for the initial route name
or just set our default screen that we
want to load first at the top of the
effect
if we want to navigate to a screen we
use the navigation.navigate
module
and we pass in the property of the
name so we pass in the component name
this pushes a new route to the stack
navigator and it is not
only if it's not already in the stack
otherwise it stays on the screen for
instance when we click the
from the new page to go to the other
page when we use navigate on the other
page and try to click the button again
it didn't go anywhere because the page
was already loaded
we also notice that the header bar will
automatically show a back button but we
can programmably go back and forth using
the go back
function
you can go back to an existing screen in
the stack with the navigate navigate i'm
sorry the navigation navigate command
or you can go back to the first screen
by using another property that i forgot
to mention here you can actually
also
use go
use
to
top
which will also jump you back to the top
so this will actually take you back to
the uh home page
that one
change the navigate here to pop to top
home
right so now if i go
into other page again
i click home it took me all the way back
and last the navigation prop is
available to all screen components
as defined as the screen in the route
configuration so if we go look here
as long as we pass in the navigation
property it is provided to us by the
navigation container
i'd like to thank you for your time if
you would like to discuss any of these
topics further you can send us questions
or comments to any of the following
methods
you can reach us at email info
developmenter.com
you can find us on our website
developernerd.com
contact us
we're also on youtube
at youtube.com slash channel slash u c z
o u f n underscore
l h c z v
d y
e two
a s
l t h underscore d
and finally you can find us on vimeo at
vimeo.com
developer our goal is making every
developer better have a great day
you
Transcript Segments
0.46

[Music]

26.96

all right so we now have our react

28.56

native so we have our components here

34.64

so now let's create a home screen for

38.48

our application

40.32

let's create a custom component so

42.879

function

45.92

on screen

54.32

and we are going to return

59.12

a view

61.76

we have view component added

64.32

so here we're going to add a view

72.479

then we're going to add some attributes

74.08

to our view

75.52

we're going to add some style

83.36

and we will add

85.119

a screen view

87.28

component to our styles in just a second

90.799

and inside of our view we're going to

92.479

add some text so let's add a text

96.32

tag and in here we will just say home

98.88

screen just so we can see that we have a

102.399

screen loaded

105.439

all right and down to our styles here

108.399

we'll add

112.799

screen view

117.759

view

121.84

and we're going to add flex

124.159

of one

127.04

we're going to add a line

130.239

item

136.08

and we're going to align them to center

142.879

and we're going to justify our content

145.84

to also be centered

151.44

save that

155.2

all right next

158.08

let's add

161.519

our stack so create a constant

165.2

we'll call it stack and this is going to

167.28

be our navigation stack for windows or

170.959

for our screens

172.959

and we're going to create

175.04

stack navigator

178.8

so we'll call the method create stack

180.48

navigator

182.64

and that creates our stack object

185.28

now in order to use the stack object and

187.84

actually put our window inside of our

189.92

stack

191.04

we come down here to our app section

193.84

let's get rid of this default view

197.2

and now we need to use a new container

201.12

our navigation container

205.2

and inside our navigation container is

207.599

we're going to apply our stack

212.08

we're going to call the navigator

215.28

module of stack

220.56

so we now have our instead of a view

223.599

we have a navigation navigation

226.4

container which contains a stacked

228.959

navigator and inside the stack navigator

231.519

we're going to add

233.28

our screen

234.319

we'll do stacked

235.84

dot screen

239.12

we're going to give it a properties name

241.519

of home

244.64

we'll use for referencing this screen

246.48

later

247.68

and the component we're going to tie it

249.76

to

250.48

is our home screen

257.04

and this is a self-closing tag

259.919

so when we save this

261.919

we now get our home screen

267.6

so we can now see that the code displays

269.6

an empty navigation bar

271.6

so no navigation bar

273.52

and gray content area containing the

276.32

home screen text

281.68

all right so that's fairly simple so now

284.24

let's set up the navigator to handle

286.88

another screen

288.56

so when dealing with the navigator we

290.88

have to configure all the routing using

293.36

properties

294.639

now in this example we did not set up

297.44

any properties because the stack by

300

default will take the first screen in

303.199

the container and use that to render the

306.72

first screen

309.52

so let's create a second screen here

314.96

let's do function

317.52

other screen

323.36

i'm going to return

330.16

another view

335.36

we're going to use our style

339.919

and we're going to use styles

342.16

and we're going to reuse our screen view

346.639

and we're going to close our view

349.84

oops access view

353.759

view

356.08

now we want to add some text

360.16

and we'll just call this another screen

369.84

okay pretty straightforward

371.84

and now to add it to the stack so we

373.919

come down here

375.6

and we copy our stack screen here

379.199

we create a new name

381.6

to reference our new screen other

384.639

and now we need to point to the new

386.4

component

390.88

we'll do other screen

392.96

and if i run this

394.4

we see we still only get home screen

399.12

however our application now has two

401.919

routes

402.88

we have a home route and another route

407.12

a route can be specified by using the

409.68

screen component

411.52

the screen component accepts a name

413.84

property which corresponds to the name

416.24

of the route we will use to navigate and

418.72

a component property which corresponds

420.96

to the component it will render

423.199

in this case the home route corresponds

425.759

to the

427.36

home screen component and the other wrap

430.08

corresponds to the other screen

432.08

component

436.72

now by default the initial route for the

438.88

stack is the home route because it is

441.28

the first screen in the stack

444.479

however if we change it to other and

447.52

reload the app

451.12

so let's change the order

455.36

so if we swap this around and save this

460.08

you'll notice that reacts natives fast

462.639

refresh won't update the changes from

465.039

the initial route name as you might

467.36

expect

468.72

instead we have to open up our console

471.199

here

474.319

and hit r to reload our screen

478.16

now we see that we have the other screen

481.12

displayed

483.039

that's because when the application

484.56

loads the first time it loads

487.599

this stack

488.96

and this does not get reloaded until the

491.199

application is closed and reopened or

493.68

forcefully reloaded

496.16

let's switch this back

504.84

save you noticed it in refresh

509.12

so we come back out here forcefully

511.36

refresh

512.8

and now we have our home screen

518.88

now there's some additional

520.479

options

521.76

and parameters you can pass

523.919

through your screen

526.48

so let's talk about how we can

528.16

specifically set the screen options and

531.2

passing additional properties

533.12

first we can use the stack screen option

537.12

attribute

540.399

which we can then use to set things like

543.2

the page title

551.6

as you can see at the top we changed

554.16

the title of our screen to home

561.519

or we might want to pass some additional

563.6

properties to a screen and we can do

565.68

this with two approaches

567.6

first we can use the react context and

570.72

wrap the navigator with a context

573.04

provider to pass data to the screens now

576

this is recommended but outside of the

578.16

scope of what we're going to cover here

580.08

today

581.2

the second approach we can use a

583.44

rendered callback for the screen instead

586.16

of specifying a component property

588.8

and to do that what you do here

592.399

is we create

594.48

we don't

597.839

they'll close the tag but instead we can

600.56

wrap the properties

602.959

inside of a props here

610

and then you can define some properties

612.399

for your particular screen now again

614.88

this is outside the scope of today but i

617.12

did want to mention this

619.6

so in case you do want to pass

621.279

properties or some values between

624

screens this is one way to do it and

626.32

we'll cover that in a future lesson

631.6

scroll this back

639.12

right so next let's look at moving

640.959

between the screens so let's look at how

642.72

we can actually navigate between our

644.24

home screen and our other

647.04

so before we look at how to navigate

648.72

between the screens let's review how

650.56

this would have worked in a web page

653.04

so

654.959

one way we can do this from a web page

660

browser

661.44

and let's get back to document stuff

666.959

so one way is to actually go to the tag

671.44

and call the page directly we can do the

674.72

anchor tag href and hard code the value

678.72

to our page

680.32

another way is to actually wrap an

683.279

element

684.959

with a onclick function that we could

688

then use the window.location.href

691.6

and then pass in the page name that we

694.48

would want to call so we can essentially

696.24

use javascript

698.079

to call an onclick command to change the

701.44

window location to a specified page

707.44

now in react native we'll do something

710

similar to the latter but rather than

712.72

using a window.location

714.959

global we will use the navigation prop

717.92

that is passed down to our screen

719.6

component

722.88

let's update our dependencies

725.519

and already added button we now have

727.839

button

729.2

which is going to act like our anchor

730.8

tag

732.24

and next we need to add a navigation

734.959

property to our screen

737.6

both add navigation

740.639

we've added a property to our home

743.68

screen

746.399

and then in here let's add a button

754.8

give it a title

761.519

go to other screen

767.279

and instead of on click we're going to

768.959

do on press

773.04

and we're going to do a self-calling

775.04

function

776.32

and we're going to call the navigation

780.88

property that we're going to pass in

783.519

dot

784.839

navigate

786.639

and then we're going to give it the

787.76

reference

789.279

that we have defined down here so we're

792

going to use the name other

795.04

so that we will call the other

797.36

screen

811.76

there we go

812.959

now it's happy

815.92

so now when we look at our screen we now

818.24

have home screen and go to other screen

823.279

so if we click go to other screen we now

825.92

navigate over to other screen and we

828.639

have the default navigation bar or

830.48

breadcrumb up here that we can use to go

832.56

back and forth between the screens

835.519

so let's recap so first we use the

838.399

navigation prop

840.399

which is passed into every screen

842.32

component in the stack navigator

845.36

then we added the navigate

849.199

other here using the navigation so we

851.76

called the navigate function in

854.079

navigation property and we passed in

857.6

the page that we wanted to go to

861.12

so this calls the navigate function of

863.36

the navigation prop with the name of the

865.6

route that we would like to move the

866.959

application to

870.56

i would like to note though that if we

872.8

call navigation.navigate

874.959

with a route name that hasn't been

877.199

defined yet

878.8

it will print an error in the

880.24

development build and nothing will

882.079

happen in the production build when you

884.48

try to run this it'll fail it'll throw a

886.32

message

892.72

right so now what happens if we keep

895.36

navigating to a route multiple times

901.36

so let's make a change

904.32

to our other screen

906.399

let's also add

908.079

navigation

915.04

and in here let's also add a button

922.32

and this time we're going to go to the

924.72

other screen again

926.8

at least we're going to attempt to

935.04

all right so over here in our

936.48

application we have our home screen

938.88

we'll click our button to go to the

940.399

other screen

941.759

now we have another button on the other

943.759

screen that if we click here

947.44

looks like it's clicking but nothing is

949.36

happening

951.04

so

953.279

if you'll notice that when we click the

955.199

go over again it doesn't do anything now

957.759

that's because we have already uh or

960.32

we're already on the other page we're

962.639

already on the other route the navigate

965.199

function roughly means go to this screen

972.24

however if you're already on the screen

974.48

then it does nothing

977.279

now if we really want the application to

979.279

add another other screen to the stack to

982.48

the route this is pretty common if we

984.959

want to pass in some unique data to each

987.6

route

988.639

so let's not touch on passing data for

991.199

now

992.24

instead let's look at how we can make

994.32

the application add another on screen to

997.519

the stack

998.72

now to do this we can change the

1000.8

navigate here

1002.56

to push

1010.639

this allows us to express the intent to

1013.279

add another route regardless of the

1015.68

existing navigation history

1021.92

so now each time we call push we add a

1025.36

new route to the navigation stack

1029.36

when you call navigate it first tries to

1031.52

find an existing route with the name

1033.76

and only pushes a new route if there

1036.16

isn't yet one on the stack

1040.959

however with push it will continue to

1043.6

push

1044.48

whatever

1046

component you're trying to add to the

1047.76

stack regardless if it's already loaded

1050.16

or not

1051.76

and now if we click other we can go back

1054.559

up the navigation till we get back to

1056.4

the home page

1060.72

so the header provided by the stack

1062.88

navigation will automatically include a

1065.52

back button when it is possible to go

1067.679

back from the active screen so if i

1069.679

click go to other screen we have this

1071.76

back button here of home which will take

1074.24

us back to the previous screen that was

1076.72

called from

1078.96

when there's only one screen in the

1080.48

navigation stack there is nothing you

1082.64

can go back to

1084.24

and so there is no back button or back

1086.64

navigation

1090.08

if we really want to rely on the stack

1092.08

to handle this behavior we can just use

1094.24

navigation. go back

1096.559

to trigger this behavior

1097.76

programmatically

1108.799

all right so let's look at another

1111.039

example

1112.4

so let's add two more buttons to the

1114.559

other page

1116.16

these buttons will allow us to return

1118.16

back to the home screen at the top of

1120.4

the stack

1121.6

we can call the nav gate not to push to

1124.64

reset to the top of the stack

1126.72

so first let's come down here and add

1129.44

another button

1137.6

we'll add a title

1141.28

of go to home

1146.72

we'll use the on press

1152.799

attribute

1154.24

and we will do a self calling function

1156.72

and we will call navigate navigation

1160.72

dot navigate

1164.72

and we will go to the home page or home

1176.84

now if i go to the other screen

1180.4

i have two buttons i have go to other

1182.799

again

1184.4

or i have go to home which returns me

1186.64

back to the top of the stack and it

1188.96

removes the back button

1192.32

now if we only want to go back one

1194.48

screen in the stack without using our

1196.799

navigation

1198.48

button at the top of the screen we can

1200.24

use the navigate function go back

1203.36

so to add another button here

1212.64

and we will name it go back

1218

on press again

1224.24

help calling function called the

1226

navigation

1228.159

and this time we will call

1230.159

go

1234.08

back

1240.159

now if i go to the other screen i now

1242.72

have the other screen again go home go

1245.76

back so if i click go back we go back up

1248.799

the queue just like if we were hitting

1250.64

the

1251.36

navigation button up here

1263.52

now one thing to note though is on

1265.44

android the react navigation hooks into

1268.559

the hardware back button and fires the

1270.88

go back function for you when the user

1273.039

presses it

1274.32

so it behaves as if the user would

1276.08

expect it to

1278.08

so again if you're on android and you

1280.159

hit the go back button it basically

1282.4

triggers the same functionality it calls

1284.88

the same go back

1287.36

function

1303.84

all right does anyone have any questions

1313.039

yeah

1315.039

i mean i've seen you do linux does this

1317.28

require a lot of linux

1321.679

no this is all uh

1323.919

app-based

1325.039

development

1326.32

the only

1327.28

uh the only the only linux piece here

1331.039

you can actually do on windows 2. but

1333.36

you have to

1334.64

kick off

1336.64

either using node or expo you have to

1339.2

start

1340.159

the

1342.159

emulator essentially for you to run your

1344.799

native applications on your desktop okay

1350.72

so it's just a command line it's not

1352.48

necessarily linux

1354.08

okay

1361.12

good question any others

1365.2

nope

1368.88

all right so let's review

1370.88

so react native doesn't have a built-in

1373.44

api for navigation like a web browser

1375.52

does

1376.48

react navigation provides this for you

1379.52

along with the ios and android gestures

1382.32

and animations to transition between

1384.4

screens

1386.159

we also talked about the stack.navigator

1388.799

which is a component that takes the

1390.48

route configuration as its children with

1393.28

additional props for configuration and

1395.919

rendering of our content

1398.88

we can also add multiple screens using

1401.6

the stack.screen component which takes a

1404.32

name property which refers to the name

1406.72

of the route and the component property

1408.96

which specifies the component to render

1410.96

for the route

1414.559

now if we want to

1417.28

specify what the initial route is

1420.48

uh in the stack it's provided we can use

1423.6

a property for the initial route name

1426.88

or just set our default screen that we

1429.679

want to load first at the top of the

1431.52

effect

1434.72

if we want to navigate to a screen we

1437.52

use the navigation.navigate

1441.279

module

1442.72

and we pass in the property of the

1445.6

name so we pass in the component name

1448.24

this pushes a new route to the stack

1450.159

navigator and it is not

1453.2

only if it's not already in the stack

1455.919

otherwise it stays on the screen for

1458.4

instance when we click the

1460.96

from the new page to go to the other

1462.4

page when we use navigate on the other

1464.88

page and try to click the button again

1466.64

it didn't go anywhere because the page

1468.24

was already loaded

1471.76

we also notice that the header bar will

1474

automatically show a back button but we

1476.559

can programmably go back and forth using

1480

the go back

1481.44

function

1486.48

you can go back to an existing screen in

1488.4

the stack with the navigate navigate i'm

1490.799

sorry the navigation navigate command

1493.919

or you can go back to the first screen

1496.24

by using another property that i forgot

1498.4

to mention here you can actually

1500.799

also

1502.48

use go

1506.08

use

1508.24

to

1511.039

top

1512.08

which will also jump you back to the top

1515.12

so this will actually take you back to

1516.64

the uh home page

1520.72

that one

1521.76

change the navigate here to pop to top

1526

home

1530.72

right so now if i go

1532.96

into other page again

1534.72

i click home it took me all the way back

1540.88

and last the navigation prop is

1542.96

available to all screen components

1546.4

as defined as the screen in the route

1548.48

configuration so if we go look here

1551.52

as long as we pass in the navigation

1553.279

property it is provided to us by the

1556.32

navigation container

1562.48

i'd like to thank you for your time if

1564.4

you would like to discuss any of these

1565.84

topics further you can send us questions

1568.32

or comments to any of the following

1570.159

methods

1571.2

you can reach us at email info

1573.2

developmenter.com

1574.799

you can find us on our website

1577.36

developernerd.com

1578.96

contact us

1580.32

we're also on youtube

1582.24

at youtube.com slash channel slash u c z

1586.96

o u f n underscore

1589.84

l h c z v

1592.08

d y

1593.2

e two

1594.32

a s

1595.36

l t h underscore d

1598.72

and finally you can find us on vimeo at

1601.12

vimeo.com

1602.72

developer our goal is making every

1605.12

developer better have a great day

1623.679

you