React Native Flashcards
React-Native Components
View
Text
StyleSheet
Which Icon library does create-react-native-app give you access to?
https://icons.expo.fyi/
import { Ionicons } from ‘@expo/vector-icons’;
touchables
Button TouchableHighlight TouchableOpacity TouchableNativeFeedback TouchableWithoutFeedback
Lists
ScrollView
FlatView
SectionList
ActivityIndicator
Is a loading spinner
props:
- size (string)
- color (‘string’)
- hidesWhenStopped (bool)
- size (String)
Button
A basic button component that should render nicely on any platform. Supports a minimal level of customization.
Props:
- onPress (function)
- title (String)
- accessibilityLabel(String)
- color(String)
- disabled(bool)
- hasTVPreferredFocus(bool)
- nextFocusDown(Number)
- nextFocusForward(number)
- nextFocusLeft(number)
- nextFocusRight(number)
- nextFocusUp(number)
- testId(String)
- touchSoundDisabled(bool)
FlatList
A performant interface for rendering basic, flat lists, supporting the handiest features:
- Fully cross-platform.
- Optional horizontal mode.
- Configurable viewability callbacks.
- Header support.
- Footer support.
- Separator support.
- Pull to Refresh.
- Scroll loading.
- ScrollToIndex support.
- Multiple column support.
item.id}
/>
Main Props:
- data={DATA}
- renderItem={renderItem}
- keyExtractor={(item) => item.id}
- extraData={selectedId}
The major difference between ScrollView and FlatList?
FlatList is more performant
ScrollView will load the entire data set, whereas FlatList will only load the data displayed in the view (recycles views)
Form Elements
Switch
TextInput
KeyboardAvoidingView
Difference between onChange and onChangeText in the TextInput component
While both methods are invoked on value change, onChangeText passes the actual value (text) as the argument. On the other hand, onChange passes the entire event object as an argument. Both are perfectly valid props, but the logic of your event handler will need to be tailored to the prop chosen.
difference between loading an image from an external server vs loading an image within the app.
In App:
from external source
What is AsyncStorage?
AsyncStorage is an unencrypted, asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of LocalStorage.
How is data stored with AsyncStorage?
AsyncStorage will use either RocksDB or SQLite based on what is available.
How to add data to AsyncStorage?
function submitEntry({entry,key}){ return AsyncStorage.mergeItem(CALENDAR_STORAGE_KEY, JSON.stringify({ [key]:entry, })) }
How to remove data with AsyncStorage?
export function removeEntry(key){ return AsyncStorage.getItem(CALENDAR_STORAGE_KEY) .then((results)=>{ const data = JSON.parse(results) data[key] = undefined delete data[key] AsyncStorage.setItem(CALENDAR_STORAGE_KEY, JSON.stringify(data)) })
}