## React Native Async Storage Usage Async storage is used to store data in the device.
async function getItem(key) {
try {
const value = await AsyncStorage.getItem(key);
if (value !== null) {
// We have data!!
return value;
}
} catch (error) {
// Error retrieving data
}
}
async function setItem(key, value) {
try {
await AsyncStorage.setItem(key, value);
} catch (error) {
// Error saving data
}
}
async function removeItem(key) {
try {
await AsyncStorage.removeItem(key);
} catch (error) {
// Error removing data
}
}
Async storage is used to store data in the device.
async function setItem(key, value) {
try {
await AsyncStorage.setItem(key, value);
} catch (error) {
// Error saving data
}
}
async function getItem(key) {
try {
const value = await AsyncStorage.getItem(key);
if (value !== null) {
// We have data!!
return value;
}
} catch (error) {
// Error retrieving data
}
}
async function removeItem(key) {
try {
await AsyncStorage.removeItem(key);
} catch (error) {
// Error removing data
}
}
It is used to load images from the internet.
import FastImage from 'react-native-fast-image';
FastImage.preload([
{uri: 'https://facebook.github.io/react-native/img/tiny_logo.png'},
{uri: 'https://facebook.github.io/react-native/img/tiny_logo.png'},
]);
import FastImage from 'react-native-fast-image';
<FastImage
source={{
uri: 'https://facebook.github.io/react-native/img/tiny_logo.png',
priority: FastImage.priority.normal,
}}
style={{ width: 50, height: 50 }}
Moment is used to format dates.
import moment from 'moment';
moment().format();
To see the preview, please visit this link.