how to store array into react-native local storage code example
Example: how to store array into react-native local storage
var myArray = ['one','two','three'];
try {
await AsyncStorage.setItem('@MySuperStore:key', JSON.stringify(myArray));
} catch (error) {
// Error saving data
}
try {
const myArray = await AsyncStorage.getItem('@MySuperStore:key');
if (myArray !== null) {
// We have data!!
console.log(JSON.parse(myArray));
}
} catch (error) {
// Error retrieving data
}