React Native II Flashcards
What are we going to learn in React Native II?

Mosh worked really hard on this course
Promise you’ll be a React-Native Ninja
Tons of Tips and Tricks
If we build an App or get a job, share story!
Advanced Concepts:
Native Device features (Android/iOS)
Navigation
Networking (Api calls)
Offline support
Authentication & Authorization
Push Notifications
Distrubution (App stores)

What do we need to know?
Ultimate React Native Part I
React Hooks
(useState, useEffect, custom hooks)
React Context
Javascript
(arrow fns, spread, async/await)
What native features are not available in React Native?
React Native has limited API for working with native features:
Camera, context not available
available as 3rd party library
Ex. image picker -> allows us to get an image from camera
have to install a library
run in iOS project
can eject from expo
or
use components by expo
lots of native features available

What is the ImagePicker component?
Can select a video or image from user’s library or camera
expo install expo-image-picker
What is useEffect (effect hook) for?
accessing lifecycle hooks like componentDidMount ( ) in functional component

How can we access a user’s camera?
ImagePicker component from ‘expo-image-picker’

What is the permissions API?

another method for accessing camera, etc.
can pass multiple permission types

How can we access a user’s library to add a photo and display on the screen?

useState() hook
to set result.uri (from ImagePicker)
display imageUri in Image component

How do we build a re-usable ImageInput component?


How do we handle the touch event of our image picker component?
consumer of ImageInput:
handles state using hooks
ImageInput:
props - imageUri, onChangeInput (reference to hook from consumer for updating data of imageUri)
wrap in a TouchableWithoutFeedback
set handlePress to fn for calling ImagePicker.launchImageLibrary

How do we build the image input list component?


How do we solve this problem?
Hint: Horizontal scrolling

ScrollView component from react-native

wrap ScrollView in a View so it only takes up content space
use useRef() hook to get current element and scroll to end
How do we design a form image picker?
wrap our ImageInputList in a new component with an error message
Just like FormPicker, FormField
allow Formik to handle state
use the values field to get form values
use the SetFieldValue method to update form values

How do we add the Form Image Picker to our Listing Edit Screen?

Consume FormImagePicker in ListingEditScreen
add validation to images using Yup schema in ListingEditScreen

How do we get the user’s location?
define function:
getLocation( ) to async call Location.getLastKnownPosition()
useEffect :
to call getLocation( )
useState:
set location and get location

What is a custom hook?
Encapsulate some state and logic around state
in a re-usable component
naming convention:
useLocation
*start with “use”

What are we going to learn in navigation?

How to take App to next level
add navigation at bottom
can click on screens
App is becoming more functional
How do we implement navigation in our React Native Apps?

What kind of navigators do we have in React?
Stack - taking users from one page to another
Tab - going between tabs
Drawer - drawing things on screen navigations
**all of them are very similar and can learn if you know one!

How do we use the stack navigator?

Each navigator is implemented in a separate library

We render StackNavigatorComponent
it knows how to navigate between components
What does React Navigation give our screen components?

A special prop called navigation
can destructure and pick navigation property
Ex. navigation.navigate(“Target Location”)
only available in screen component
not available in child components
.push creates a new instance on the stack
.navigate creates a single instance on stack
but can use navigation hook to access navigation object

How do we access navigation prop using React Navigator hook?
useNavigation( ) hook

How do we pass parameters to React Navigator?
ex. pass ID of a specific tweet

How can we set the title of a screen?

using the options prop of the Stack.Screen component


















































































































































