Async Storage trong React Native là gì?
Async Storage trong React Native là gì?
AsyncStorage là kho lưu trữ key–value bất đồng bộ, không mã hoá, bền vững (tương tự localStorage) của package @react-native-async-storage/async-storage.
import AsyncStorage from "@react-native-async-storage/async-storage";
await AsyncStorage.setItem("token", "abc");
const token = await AsyncStorage.getItem("token");
await AsyncStorage.setItem("user", JSON.stringify(user));
const u = JSON.parse((await AsyncStorage.getItem("user")) ?? "null");
await AsyncStorage.multiSet([["a", "1"], ["b", "2"]]);
await AsyncStorage.removeItem("token");
await AsyncStorage.clear();
JSON.stringify).Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.