React Native I Flashcards

1
Q

What are we going to learn?

A

How to build fast and beautiful apps in react native

learn everything from scratch

all code explained

real world app

selling things you don’t need

login/register

see where item is on map

send message to seller

push notification to seller

can filter lists

can add a new listing

beautiful animation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What should we know to get started?

A

Javascript

React because React Native is built on top

it targets mobile platforms

components

JSX

props

state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is React Native?

A

a framework for building native apps for iOS and Android

build truly native apps

don’t need to know iOS or Android programming

only need iOS/Android if app is complicated, need to talk to their native APIs directly

write all app code in Javascript

a lot of companies prefer to build apps using React Native

don’t need two developers / code bases

Five Apps built using React Native:

Facebook

Instagram

Pintrest

Skype

Uber Eats

Use your skills to build a real App in React Native

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can you use React Native to build a serious app?

A

misconception:

can only build a serious app using native language (iOS or Android)

Five Apps built using React Native:

Facebook

Instagram

Pintrest

Skype

Uber Eats

Use your skills to build a real App in React Native

the best tool to use to build native apps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two ways to build React Native apps?

A

Plain React Native

React Native command line interface

android / ios folders (native projects)

Javascript code on side, can share across

for people with some experience with mobile development

Expo CLI

a set of tools and framework that sits on top of React Native

hides a lot of complexity

makes it incredibly fast and easy

with no experience, can build app in a few minutes

only have Javascript code

cannot work natively with API of iOS and Android

gives a lot of native features

can customize native components by ejecting from Expo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can we debug our React Native apps inside VSCode?

A

React Native Tools plugin by Microsoft

React-Native/React/Redux snippets to generate code fast

material Icon theme - files get pretty icons depending on type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s in a React-Native project folder?

A

assets

all images, videos, audio files, etc. to bundle with app

App.js

basic React-Native component

import React, components from React-Native

no HTML elements - use components by React-Native

is like a

when compiled, translated .css like stuff is compiled to the native widgets (iOS / Android)

represent elements in platform independent way

React Native maps to native widgets during compilation

apps built with React Native are real native apps (because compiles to native code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Metro Bundler?

A

Javascript bundler for React Native

responsible for compiling all JS files into a single file

allows us to publish to expo (no need for App store) for anyone to view app

**only for development / testing (not production)

can send an email for people to view app

can open in expo app to view app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can we view our React Native app on an iOS simulator?

A

download xtools

run iOS simulator

fast refresh - can see updates immediately in simulator

control + D to bring up developer menu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can we setup an android virtual device to run our React Native apps?

A

during development

easier to run on emulator or simulated device

install Android studio

add export to bash file and .zshrc

https://docs.expo.io/workflow/android-studio-emulator/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do we test our app on a real device?

A

simulators are great

but testing on a real app is important

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can we debug our React Native apps in Chrome?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can we debug our app using chrome developer tools?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can we debug our React Native apps in VScode?

A

command + m (android virtual)

enable remote debugging

close browser window

React Native tools (VScode extension)

create a launch.json file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do we publish or apps in expo?

Hint: $ expo publish

A

much easier than dealing with App stores

purely for development and testing purposes

can publish in Metro bundler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What fundamental concepts are we going to learn?

A

The components and core APIs we will use most

learn foundations and learn other components / APIs on your own

full list available:

https://reactnative.dev/docs/components-and-apis

components for building user interfaces

cross platform components

will map to Native equivalent

have specific components for android/iOS

can give us access to Native APIs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is view component?

Hint: like div

A

don’t have HTML elements like div, paragraph, etc

have to build UI using React Native components

is most basic / fundamental component

used to group / lay out children

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the text component?

A

Second most fundamental component

used for displaying text

always wrap in component

Props:

numberOfLines

numberOfLines = { }

can truncate lines if too long

onPress = {handler}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What should I get used to when building apps in React Native?

A

Reading React Native docs

gives better understanding of capabilities and limitations of components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the image component?

A

can display local images bundled with app

network images downloaded from internet

Local Images

use .require function ( )

WARNING:

react native packager will include file in bundler (.require)

increases size of app

use if really need to be included (like icon, splash screen)

otherwise download from internet

Network Images

pass an object to image component with property uri: set to URL

manually specify dimensions

Props

blurRadius

loadingIndicatorSource

fadeDuration

resizeMode

if image is different size than what we specify

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are Touchable components?

A

We can make anything touchable

TouchableOpacity

makes image temporary white fade

TouchableHighlight

makes image temporarily black fade

onPress event

can handle events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the component?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the alert function( ) ?

A

alert we display gets map to it’s native equivalent

can customize title, etc. using Alert api

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How can we create custom alert messages?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
**What** is the **StyleSheet Api?**
can define styles below component convention to define styles below component Mosh prefers to have style below components **styles are not CSS** **inspired by CSS but** just **javascript properties** essentially **passing a plain JS object** **React Native** will **maps component** to **native counterpart and apply the styles** **why use StyleSheet.create ({ })** **validates what we pass as styles** **returns an object** **validates properties ensuring we don't misspell a word, etc.**
26
**How** do we **detect the platform our app is running** and **apply custom Native features?**
Platform module
27
**What** are we **going to learn in layouts?**
How to **create layouts in React native** Will **build first two screens** of **our app** will **use material in excercises** at **end of the section**
28
**How** many **apps do users have these days?**
**Only 3** are **used most of the time!** ## Footnote **App market is incredibly competitive**
29
**What** is **density independent pixels**?
**view** looks **roughly the same** across **devices**
30
**How** do we **detect rotation and resize components** accordingly? **Hint**: npm i @react-native-community/hooks
update **app.json orientation to "default"** **use hook** from **react-native-community** **always returns updated dimensions** **everytime screen changes, this hook recalculates dimensions**
31
**What** is **Flexbox**?
library for **building complex layouts** that work **consistently across different screens** How? setup a **view as container** **set flexDirection and justifyContent properties** **align children inside container**
32
**How** can **we align items** along the **main or primary access?** ## Footnote **Hint: flexDirection**
**flexDirection:** **"row"** align horizonatally **"column"** align veritically
33
What is "**column-reverse" and "row-reverse" flexDirections?**
means of aligning content in our container **column-reverse** align across vertical axis (primary) in reverse **row-reverse** align across horizontal axis (primary) in reverse
34
**How** do we **align items (children) across the primary axis in our container (parent)?** ## Footnote **Hint: justifyContent**
**justifyContent property** in **our container** **sets alignment for children** **"center"** align items at center of main access **"flexend" / "flex-start"** align items at end or start of main access **"space-evenly"**
35
**How** do we **align items** accross the **secondary axis?** **Hint:** alignItems
**alignItems property** aligns across secondary axis **"center"** aligns in center of secondary axis **"baseline"** gives content same baseline **"flex-end"** items appear at end of secondary axis **"stretch"** default behavior aligns all the way across secondary axis
36
**How** can we **align an individual item** in a **container?**
**alignSelf property**
37
**What** is the **default behavior** if **one or more of our items** **overflow across the main access?** **Hint**: noWrap
**noWrap** one or more items **get shrunk** **solution?** **enable wrapping** **flexWrap: "wrap"** **puts additional content on a new line and maintains dimensions**
38
**What** is the **difference** between the **"alignContent" property** and the "**alignItems" property?**
**alignItems** determines alignment of items within each line if multiple lines, aligns each line according to secondary axis Ex. second line items are aligned in center! **alignContent** determines alignment of entire content \*only works if we have wrapping
39
**What** is **flexBasis, flexGrow and flexShrink?**
**flexBasis** equivalent to setting height / width depending on main axis **flexGrow** item will grow to fit available space exactly the same as setting flex property in item **flexShrink** not used often opposite of flexGrow shrinks item if there is overflow
40
**How** do we **move items** in our **container up, down, left or right?**
top bottom left right \*moves **position relative** to **others without affecting overall layout**
41
**What** is **relative vs. absolute** positioning in **react native?**
**by default,** position set to **"relative"** move relative to position without layout being affected **absolute** positioned relative to parent other views move around and are not in original positions
42
**How** do we **build the welcome screen** of **our app using React Native?**
43
**How** do we build the **ViewImageScreen** in **React Native?**
44
**How** can we **refactor this code?**
**duplication of color codes** **repeated** in **multiple places** **extract** and **put in separate files** **can rebrand** and **use diff colors (single file to modify)**
45
**What** are we going to **learn in the section on styling?**
**how** to build **beautiful user interfaces** implement new screen and **re-usable components** **various style properties** **organizing styles** **platform-specific styles** **icons to build beautiful interfaces**
46
**How** do we **add boarders** to **our views?**
setting **borderRadius** to at **least 50% size** ## Footnote **makes a circle**
47
**How** do we **apply a shadow?**
**iOS** **requires setting three properties** **shadowColor** **shadowOffset** - position of shadow **shadowOpacity** - how dark **Android** **only one property, cannot control much** elevation
48
**What** is the **difference between padding and margin?**
**padding** the space inside a component **margin** the space outside a component
49
**How** do we **apply padding and margins?**
padding paddingHorizontal paddingLeft paddingRight margin marginHorizontal marginLeft marginRight
50
**How** do we **apply styling to text?**
**only** available for **Text** **no style inheritance** in React Native **fontFamily** have to use Platform API to determine device iOS and Android have different font types **fontSize** **textTransform** **textAlign** multiple lines right or left align **fontWeight** **lineHeight** space between lines **Platform specific fonts** https://github.com/react-native-training/react-native-fonts
51
**How** do we **ensure all text** looks the **same across multiple components?**
**encapsultating style** encapsulate all styles for text inside a custom text component create a custom text component **used like a text component** encapsulates all styles
52
**How** can we **find icons?**
**almost every app uses icons** **expo vector icons** **available (imported) with expo project**
53
**How** can we **add icons** to our **React-Native project**?
54
**What** is the **challenge with this code?**
**setting** many **platform specific styles** this **way is unmaintainable** **have** to use **'Platform.OS == android ? x : y'** everytime **duplicating code!** Soln? **Platform.select** takes a key-value pair returns an object **spread (...) properties** into **StyleSheet object**
55
**How** can we **separate platform specific behavior?**
useful if **want to customize behavior and styles** create separate files for platform specifics **example** - AppText.ios.js, AppText.android.js
56
**What** is **another approach** for **this implementation?**
create separate files React-Native will automatically know which to insert depending on device!
57
**How** do we **create the login button component?**
58
**How** can we **add the login and register button** to our **welcome screen?**
59
**How** do **we build** the **Card component?**
60
**How** can **we build** the **ListingDetailsScreen?**
61
**How** do we **implement the listing author** component **(ListItem)?**
62
**How** do we **replace the placeholders with buttons** in our **ViewImageScreen?**
63
**What** are **UI libraries?**
**In this course,** you learn **how to build UI components from scratch because that's an essential skill you need to master.** **But in a real app**, you may want to **use a UI toolkit**. These toolkits are great. They have **beautiful components that you can easily add to your apps.** **React Native Elements (My Recommendation):** https://react-native-elements.github.io/react-native-elements/ **React Native Paper:** https://callstack.github.io/react-native-paper/ **Native Base:** https://nativebase.io/
64
**What** will **we build in the list section?**
**every app** needs to **present a list of data** **Building:** Three new screens a bunch of re-usable components
65
**What** is **Flatlist** **React Native component?**
**used** for **rendering flat lists** ## Footnote **includes:** **headers** **footers** **pull to refresh** **scroll loading**
66
**How** do we **solve the problem of this list being in the corner of our screen?**
**SafeAreaView** **The purpose** of **SafeAreaView** is to **render content** within the **safe area boundaries of a device**. It is **currently only applicable** to **iOS devices** with **iOS version 11 or later.** **Soln** **detect OS type and if android, use another option** **alt?** **expo constants**
67
**What** is **an alternative approach** for **implementing padding** at **the top** of the **MessagesScreen?**
68
**What** are **expo-constants?** **Hint:** npm i expo-constants
an object with a bunch of useful properties device, etc **statusBar Height** 24px android 44px iOS
69
**What's** the tiny **problem with this implementation**?
everytime **we want to make a new screen** with a SafeAreaView have to **re-write code** use **Expo constants, etc.** **Soln?** Extract a re-usable component
70
**How** do we **add separation between our items in the list?**
**FlatList component** has an **ItemSeparatorComponent** property
71
**What's the problem** with **this implementation**?
**Chances are...** we will **have another FlatList component in our App** **soln?** **we want** to **extract a re-usable separator component**
72
**How do we implement the MessageScreen using re-usable components?**
73
**What** don't we **want to do here?**
handle the **logic for the onPress event** in **ListItem** component **Why?** component should be re-usable in one context, display alert on tap in another context, take user to another screen **should be** determined by **consumer of ListItem componen**t Ex. **MessageScreen** should determine what should happen when user taps on a message (ListItem) Soln?
74
**How** do we **implement** the **ListItem** **onPress event** in our **MessagesScreen?**
75
**What** is **gestureHandler**?
**a library** for **handling gestures** ## Footnote **use swipeable (API docs)** **to incredible left/right swipe features**
76
**How** do we **create the swipe** render **action?**
77
**How** can we **refactor this?**
**extract renderRightActions logic** **put** this **logic** into a **re-usable component** **ListItemDeleteAction.js**
78
**How** do we **implement handling a swipe?**
79
**How** do **we implement** **deleting a message** in the **MessagesScreen?**
**Logic** for **onPress** in **caller of this component** (MessagesScreen) **Why?** **So** we can **re-use** the **ListItemDelete action** component **Also** **Hooks** for **stateless functional components** **useState**
80
**How** can we **re-write this code?** ## Footnote **Hint: setCount similar to setState but for sfc vs. class components**
useState() takes an initial state returns an array array[0] is variable array[1] is a fn for updating variable
81
**How** do we **handle deleting an item?**
**Where we use the ListItemDeleteAction component** is where **we should define the onPress action (MessagesScreen)** ## Footnote **pass fn into ListItemDeleteAction as a prop (onPress)** **simply delegate onPress to this fn**
82
**How** do we **implement** pull to refresh in our **MessagesScreen?**
**pass additional props to FlatList component** refreshing
83
**How** do we **create a re-usable Icon component?**
84
**How** should we **approach building this screen?**
**extract logic into a re-usable component** **build a re-usable Icon** create **a view** that **acts as a container for ListItem** **add some margin** render a **FlatList componen**t for **myListing/myMessages** create **a view** that **acts as a container for Logout Item**
85
**How** can we **extend our ListItem** component and **give ability to render an icon?**
**render image only if prop given** {image && } basic conditional rendering **wrap in braces using && operator**
86
**How can** we change the **Screen component** to allow **alternative styles** to be **passed as props?**
declare an additional prop (style) pass an array of styles to the SafeAreaView component
87
**How** do we **make our list items stand out?**
**Before,** **ListItem component** has **no background** **what we see** if background of **screen component** add **backgroundColor to ListItem details**
88
**How** do we **build the account screen**?
89
**How** do **we build** the **Listings Screen?**
90
**What are we going** to **learn** in the **section on input components?**
**Getting input from the user** **Learn:** **input components** available in **React Native core** **Building pretty input boxes** **build** a **custom input** feature **from scratch**
91
**What component do we use to get text from the user?**
**TextInput component** **useful props:** autocapitalize autocorrect autofocus
92
**How** do we **refactor this code** to **create a beautiful, re-usable component?**
93
**How** do we **pass props** into a **composite component?**
use **spread operator** to get **all other props** **pass this object** to **composite component** Ex. at first, **only desctructured icon props** **Then**, **added ...otherProps** so we **can pass placeholder** prop to **TextInput component**
94
**How** do **we create** a **re-usable input component**?
95
**How can** we **refactor this code**?
**extract style** into a **separate file** **import** into **AppTextInput module**
96
**What** is the **Switch component**?
**setValue** prop to a **state variable** handle **onVariableChange to update state variable**
97
**How** do we **create the foundation of the AppPicker component?**
98
**How** do we **edit this code to display a modal box (to choose elements)?**
In **user interface design for computer applications,** a modal **window is a graphical control element** subordinate to an application's **main window.** It creates **a mode that disables the main window** but **keeps it visible**, with the modal **window as a child window in front of it.** **Soln?** **Wrap** in a **touchable component** to **handle** onPress event **using hooks**, set **visible to true** during **onPress event**
99
**How** do we **implement AppPicker component?** **Hint:** TouchableWithoutFeedback, Modal, FlatList, PickerItem
100
**What** are we **going to build in the forms section**?
Going to **take app to next level** ## Footnote **add login form** **add register form** **add form to create a new listing** **Learn:** **how to valid form input data** **how to build re-usable form components** **popular libraries**
101
**How** can we **build the login screen?**
Custom Screen composed of: useState setEmail, setPassword \< Screen \> \< Image /\> \< AppTextInput /\> autoCapitalize autoCorrect icon onChangeText - setEmail / setPassword placeholder secureTextEntry textContentType \< AppButton /\> \< Screen \> rnss
102
**What's the problem** with this **approach to building forms**?
**Unmaintainable** as **we add more fields** **Why?** **For every new field**, must **set a state variable** (create hook) have to **write code to validate variable** **can get painful with a lot of fields** **Soln?** Formik **popular library for creating forms** eliminates need to use hooks tracks our state for us!
103
**What** is F**ormik?** **Hint**: npm i Formik
**Popular library** for building **forms in React-Native** know **what it is** and **how it works** **probably** in your **next React-Native project** **you'll use it in every project and love it** **Why?** Takes **care of complexity** of **building forms** keeps track of **form state** gives **validation out of box** **works with React** and **React Native** **Trusted in production?** **Lyft, Walmart, Booking.com, Nasdaq, US Army**
104
**How** do we **refactor this code?** Hint: Formik
105
**What** is **Yup?**
**validation library like Joi** **Formik** has **integration with Yup** **chain methods** to **build a complex schema**
106
**How** do we **implement validation** using **Formik** on our **LoginScreen?**
107
**How** do we **refactor this code**?
108
**How** can we **show an error message** only if the **input** field **has an error & has been touched**?
**handle** **onBlur event** **add visible** as **another prop**
109
**How** do we **refactor this code?**
**In each...** have to handle error message handle onBlur handle onChangeText **refactor...**
110
**How** do we **re-factor this code?**
**Extract SubmitButton** into a **re-usable component**
111
**How** do we **refactor this code?**
112
**How** do we **re-organize these folders**?
113
**How** do we **build the register screen**?
114
**How** do **we build** the **Listing Edit screen?**
115
**What** do **we have** to do in the **final section of React-Native (part one)?**
**Imagine** we **got hired** as a **React-Native developer:** **Real world situation:** given a new project build by someone else have to fix a number of issues have to implement a new feature **Excercises:** very important especially the last excercise
116
**Why** do **we need** to create the **AppFormPicker component**?
**Wraps** Formik Context around **AppPicker component** **Why?** Allows us to **access formik Contex**t for **passing data**
117
**How** do we **refactor this code?**
118
**What** is **an issue that happens frequently** in **mobile apps?**
Long Text **Soln?** **Always test** components **with long text**
119
**How** can we **solve this issue?**
**apply** maxNumberOfLines **use** bring other props ...otherProps pass { ...otherProps } to Text component
120
**How** can we **fix this code?**
Already **added the ability to pass additional props** to AppText component pass **numberOfLines prop in Card** component
121
**How** do we **dynamically display** the **price width**?
**remove** **"width"** from **AppTextInput component container style**
122
**How** do we **dynamically set** the **width of the picker component?**
123
**How** do **we create** the **CategoryPickerItem component**?
**re-usable component** **extensible** design of **AppPicker and AppFormPicker** pass a **PickerItemComponent** dynamically **using props** set **CatagoryPicker** as **PickerItemComponent** in **ListingEditScreen**
124
**What is repetative** about **creating a new component?**
**Have to do a few steps:** rsf **(react stateless function)** rnss **(react native stylesheet)** render a import **rn view, stylesheet** **apply a style** to the view container **Soln?** Custom snippets
125
**How** do we **create a react snippet?**
code -\> preferences -\> snippets