📺 Develpreneur YouTube Episode

Video + transcript

React Native Fundamentals - Part 15 - Required Libraries

2021-11-11 •Youtube

Detailed Notes

In this video, we take a tour of some of the required libraries for our react native applications.

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 welcome so today we are moving
on to the next section of our react
native discussion and that is talking
about navigation through
react through our mobile applications
how do we change screens how do we uh
you know click a button to go to a
different screen work through that
like tab navigations menu navigations
things of that nature so today is the
first discussion we're going to have on
react navigation
we're going to talk about things like
what are the required dependencies that
we need to install before we can
actually start navigating through our
application through our screen
and then we're going to look at
specifically the react navigation
modules or libraries that we can get for
react
now before we get started let's talk
about screens
now more specifically what are they if
we were viewing our application in a web
browser then the screen would be our web
page
however in react native a screen is made
up of views scroll views safe area views
now when we're talking about mobile
applications they are rarely made up of
single screens so therefore we need to
learn how to use three act navigator to
handle the presentation of and
transition between multiple screens
so with react navigation
the community solution to navigation is
a standalone library that allows
developers to set up the screens of an
app with a few lines of code
now before we begin we need to install
some of the additional dependencies for
npm
and expo and these dependencies consist
of the react native gesture handler the
react native reanimated
react native screens
react native safe area context
react native immunity
forward slash mask view
react navigation slash stack
now to install these we need to just go
out to our console and we can install
them with the npm
expo
and any of the other installations that
we need
now we're going to jump out now and
actually get started with the hand on
presentation
i'll open up my console here
so
to install our dependencies if we are
using node we're going to use npm
move this
zoom out of my way we got npm
and then you do install
and to install all those
react native navigate uh sorry the react
native
dependencies we do at
react
dash native
or react
navigation slash native
hit enter
and this will install all the
dependencies
and there we go the warnings are okay
and there are some vulnerabilities and
whatnot depending upon your version of
node or expo you may have to install
some additional updates for fixes
and if we do expo
install
react
native
so unfortunately though for react we
have to actually install each of these
modules separately whereas by doing the
npm install react native navigate
navigate
we actually get
all of these
uh
modules or libraries installed for us
now we still need to install this guy
for node so let's go ahead and do him
first
so if we do
npm install
right now slack or stack
clear and if we do expo
stall
may not work
if
one line
yep
so you install
to expo i've already done this and this
will take a minute to install
yeah because i've already done that okay
all right so we already have the expo
components now if you have a bare react
native project you'll need to install
the dependencies with npm
like i just showed you before
however um there are also some
additional settings for ios with bayer
react native project
we will not be covering that today
however if you are planning on building
a bear react native project go check out
the documentation on reactnative.dev
for more information on how to set the
additional settings you need to set up
all right so
let's talk about react navigation so
before mobile apps we had web pages and
browsers so in order for us to navigate
to different pages on a web page we had
to use the anchor tag
so let's go look at a browser real quick
and see what an anchor tag looks like
a browser
here we have chrome and let's go to
stuff.com
i always pick on my site
it may or may not come up yeah there it
is
all right so each of these links here
this is how we would navigate through
our site and if we actually inspect this
guy
click on it
yep so if we inspect it
we see we have an anchor tag and a with
an href
now this is how we navigate in a web
browser so when the user clicks on a
link the url is pushed to the browser
history stack so if the user presses the
back button the browser properties
takes the item from the top of the
history stack
and loads it up so it becomes the active
page and now the page that we are
currently on becomes the previously
viewed page
so we will need to use react navigation
because react native doesn't have a
built-in idea of a global history stack
like a web browser does
react navigation stack navigator
provides a way for your app to
transition between screens and manage
navigation history
so if your app uses only one stack
navigator then it is conceptually
similar to how a web page browser
handles navigation state
your app pushes and pops items from the
navigation stack and
uses the users can interact with it and
this results in their in the user seeing
the different screen
another key difference between how this
works in a web browser and in react
navigation is that react navigation
stack navigator provides the gestures
and animations that you would expect on
android and ios when navigating between
routes in the stack
and before we can use the stack
navigation library we need to install
another library and for that we
installed
the react navigation stack
now
since we've now installed all of our
libraries we are now ready to build and
run our applications on our device and
simulators
so let's create a new application
come into my workspace here and we'll do
an expo
init
sample app five
we're gonna do another blank
or bare canvas application
all right my network's a little slow
today not sure why
there we go
all right now it's created our project
so it tells us first we need to go in
to our sample app five so we're going to
sample that five
now since we're using expo we're not
going to use the node commands here
instead we're going to do expo
start
now open up another tab here which will
be in my sample app five directory
and we will type code dot to open up
visual code
all right visual code is opening
expo is started
so let's actually
open up and run some apps
let's open an ios simulator
all right that's opening up the ipad
and i also want to open up
okay the ipad opened up to our default
app
loaded expo all the new updates
and iphone 8 is still loading
open
and there we go
so we now have our app
running so expo is running and we've
deployed to two applications
let's minimize our console we're done
with that for now
and let's go over to our app and open up
the apps
the app.js file and this is our basic
application here
so the first thing we know is we have
our input status bar that gives us that
expo status bar when we shake the device
you use the react files we need to
import react from react
and we need some basic
screen functionality so we have view
text and style sheet
now we need to add an additional feature
here so let's actually move our react
here
up to the top
and let's actually import all
so now we're pulling in everything from
react
sorry about that
hide these meetings
okay everything's still working
all right we have our input status bar
we have our view
so next we need to actually import our
navigation container and the stack
navigator
here we're going to do import
and then we want the
navigation
container
from
react
dot
navigation
native
and import
create
staff
navigation or navigator
um
native yeah
navigation
this gets to be a bit of a tongue tie so
i apologize
stack
navigation
with stack
view style okay
here make sure i didn't spell anything
ah
okay react navigation not in my folder
so we'll go back out here
stop
expo for a moment
since i reinstalled
node i need to make sure i reinstall it
for expo
and i need to make sure i do it inside
of the application
let's restart
expo
that's a good little error because it
actually showed us that what happens
when you do not install react native in
the correct folder
the load
enable to resolve that
there we go
may not be represented
oh yeah
right there
there we go
man
oops
there
[Music]
expo
all right now let's do xbox start
there we go
now the apps are loading without an
error
so if you do not load
the
react native
components inside of your project
then they will not be accessible
you
Transcript Segments
0.42

[Music]

27.199

all right welcome so today we are moving

29.84

on to the next section of our react

32.079

native discussion and that is talking

33.92

about navigation through

36.399

react through our mobile applications

38.399

how do we change screens how do we uh

41.12

you know click a button to go to a

42.64

different screen work through that

45.28

like tab navigations menu navigations

47.68

things of that nature so today is the

49.76

first discussion we're going to have on

51.76

react navigation

53.84

we're going to talk about things like

55.76

what are the required dependencies that

57.36

we need to install before we can

58.8

actually start navigating through our

60.879

application through our screen

62.879

and then we're going to look at

64

specifically the react navigation

67.36

modules or libraries that we can get for

70.08

react

72.159

now before we get started let's talk

73.92

about screens

75.52

now more specifically what are they if

78.32

we were viewing our application in a web

80.479

browser then the screen would be our web

82.799

page

83.92

however in react native a screen is made

86.64

up of views scroll views safe area views

90.64

now when we're talking about mobile

92.24

applications they are rarely made up of

94.88

single screens so therefore we need to

97.28

learn how to use three act navigator to

100.24

handle the presentation of and

102.159

transition between multiple screens

107.68

so with react navigation

110

the community solution to navigation is

113.759

a standalone library that allows

115.759

developers to set up the screens of an

118.24

app with a few lines of code

120.96

now before we begin we need to install

123.28

some of the additional dependencies for

125.68

npm

126.88

and expo and these dependencies consist

130.239

of the react native gesture handler the

133.36

react native reanimated

135.76

react native screens

139.28

react native safe area context

142.64

react native immunity

145.2

forward slash mask view

147.84

react navigation slash stack

151.28

now to install these we need to just go

153.36

out to our console and we can install

156.08

them with the npm

157.599

expo

159.04

and any of the other installations that

161.599

we need

162.56

now we're going to jump out now and

164.48

actually get started with the hand on

166

presentation

172.08

i'll open up my console here

174

so

175.04

to install our dependencies if we are

177.84

using node we're going to use npm

183.36

move this

184.4

zoom out of my way we got npm

187.599

and then you do install

191.519

and to install all those

193.2

react native navigate uh sorry the react

196.4

native

197.36

dependencies we do at

200.8

react

203.92

dash native

206.48

or react

210.84

navigation slash native

215.36

hit enter

217.76

and this will install all the

218.879

dependencies

233.28

and there we go the warnings are okay

235.599

and there are some vulnerabilities and

237.439

whatnot depending upon your version of

240.239

node or expo you may have to install

243.12

some additional updates for fixes

246.799

and if we do expo

249.76

install

254

react

255.76

native

258.88

so unfortunately though for react we

260.799

have to actually install each of these

262.479

modules separately whereas by doing the

266

npm install react native navigate

268.96

navigate

272.56

we actually get

274.08

all of these

275.68

uh

276.72

modules or libraries installed for us

279.919

now we still need to install this guy

281.919

for node so let's go ahead and do him

284

first

285.84

so if we do

288

npm install

292.4

right now slack or stack

304.8

clear and if we do expo

307.68

stall

316.16

may not work

317.52

if

318.4

one line

320.8

yep

326.24

so you install

328.56

to expo i've already done this and this

330.639

will take a minute to install

333.44

yeah because i've already done that okay

336.4

all right so we already have the expo

338.56

components now if you have a bare react

342.16

native project you'll need to install

344.4

the dependencies with npm

347.44

like i just showed you before

349.72

however um there are also some

353.039

additional settings for ios with bayer

355.36

react native project

357.36

we will not be covering that today

359.44

however if you are planning on building

361.919

a bear react native project go check out

364.72

the documentation on reactnative.dev

367.759

for more information on how to set the

370.96

additional settings you need to set up

377.52

all right so

381.52

let's talk about react navigation so

384.319

before mobile apps we had web pages and

387.84

browsers so in order for us to navigate

390.479

to different pages on a web page we had

392.56

to use the anchor tag

395.12

so let's go look at a browser real quick

397.199

and see what an anchor tag looks like

400.4

a browser

406.479

here we have chrome and let's go to

410.639

stuff.com

413.52

i always pick on my site

415.44

it may or may not come up yeah there it

417.12

is

418.16

all right so each of these links here

420.479

this is how we would navigate through

422.72

our site and if we actually inspect this

425.52

guy

428.479

click on it

430.88

yep so if we inspect it

434.08

we see we have an anchor tag and a with

436.4

an href

437.68

now this is how we navigate in a web

440.24

browser so when the user clicks on a

442.4

link the url is pushed to the browser

444.8

history stack so if the user presses the

447.52

back button the browser properties

451.039

takes the item from the top of the

452.639

history stack

454.08

and loads it up so it becomes the active

456.24

page and now the page that we are

458.8

currently on becomes the previously

460.88

viewed page

469.44

so we will need to use react navigation

472.319

because react native doesn't have a

474.639

built-in idea of a global history stack

477.84

like a web browser does

480.24

react navigation stack navigator

483.36

provides a way for your app to

485.039

transition between screens and manage

487.84

navigation history

489.599

so if your app uses only one stack

492.4

navigator then it is conceptually

494.4

similar to how a web page browser

496.479

handles navigation state

498.72

your app pushes and pops items from the

501.52

navigation stack and

504.84

uses the users can interact with it and

508.4

this results in their in the user seeing

511.28

the different screen

514.56

another key difference between how this

516.56

works in a web browser and in react

518.88

navigation is that react navigation

521.68

stack navigator provides the gestures

524.399

and animations that you would expect on

526.88

android and ios when navigating between

530

routes in the stack

533.36

and before we can use the stack

534.72

navigation library we need to install

537.04

another library and for that we

539.12

installed

540.32

the react navigation stack

544.88

now

545.68

since we've now installed all of our

547.12

libraries we are now ready to build and

549.44

run our applications on our device and

551.6

simulators

553.519

so let's create a new application

559.839

come into my workspace here and we'll do

562.16

an expo

564.08

init

566.32

sample app five

572.16

we're gonna do another blank

574.08

or bare canvas application

579.12

all right my network's a little slow

580.959

today not sure why

593.12

there we go

594.72

all right now it's created our project

597.2

so it tells us first we need to go in

599.92

to our sample app five so we're going to

602.959

sample that five

606.64

now since we're using expo we're not

609.12

going to use the node commands here

610.959

instead we're going to do expo

615.279

start

621.76

now open up another tab here which will

623.839

be in my sample app five directory

626.56

and we will type code dot to open up

628.72

visual code

635.519

all right visual code is opening

638.399

expo is started

640.16

so let's actually

641.68

open up and run some apps

646.24

let's open an ios simulator

652.399

all right that's opening up the ipad

656.959

and i also want to open up

683.76

okay the ipad opened up to our default

685.92

app

688.399

loaded expo all the new updates

691.12

and iphone 8 is still loading

696.88

open

709.6

and there we go

711.12

so we now have our app

712.8

running so expo is running and we've

715.279

deployed to two applications

720.72

let's minimize our console we're done

722.32

with that for now

724.079

and let's go over to our app and open up

726.48

the apps

728

the app.js file and this is our basic

731.6

application here

733.6

so the first thing we know is we have

735.68

our input status bar that gives us that

737.76

expo status bar when we shake the device

741.92

you use the react files we need to

744.32

import react from react

746.72

and we need some basic

749.04

screen functionality so we have view

751.279

text and style sheet

754.24

now we need to add an additional feature

757.2

here so let's actually move our react

761.04

here

762.8

up to the top

765.36

and let's actually import all

772.959

so now we're pulling in everything from

774.56

react

788.959

sorry about that

791.44

hide these meetings

804.639

okay everything's still working

806.959

all right we have our input status bar

808.72

we have our view

810.16

so next we need to actually import our

813.04

navigation container and the stack

815.68

navigator

819.6

here we're going to do import

825.279

and then we want the

828.959

navigation

831.6

container

834.56

from

843.519

react

844.88

dot

846.16

navigation

848.72

native

862

and import

866.32

create

867.839

staff

869.199

navigation or navigator

877.519

um

882.839

native yeah

885.639

navigation

887.519

this gets to be a bit of a tongue tie so

889.68

i apologize

891.12

stack

897.68

navigation

900.079

with stack

904.079

view style okay

921.92

here make sure i didn't spell anything

945.92

ah

947.519

okay react navigation not in my folder

950.399

so we'll go back out here

954

stop

956.72

expo for a moment

966.72

since i reinstalled

968.72

node i need to make sure i reinstall it

970.8

for expo

980.399

and i need to make sure i do it inside

982.16

of the application

996.079

let's restart

998.079

expo

1006.639

that's a good little error because it

1008.24

actually showed us that what happens

1010.8

when you do not install react native in

1013.36

the correct folder

1015.759

the load

1018.88

enable to resolve that

1051.2

there we go

1055.76

may not be represented

1062.32

oh yeah

1081.919

right there

1114.4

there we go

1120.64

man

1137.2

oops

1147.44

there

1151.46

[Music]

1156.24

expo

1184.32

all right now let's do xbox start

1221.28

there we go

1223.919

now the apps are loading without an

1225.679

error

1229.039

so if you do not load

1231.2

the

1233.039

react native

1234.799

components inside of your project

1237.36

then they will not be accessible

1255.679

you