Answers for "how to store array into react-native local storage"

1

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
}
Posted by: Guest on June-06-2021

Code answers related to "how to store array into react-native local storage"

Code answers related to "Javascript"

Browse Popular Code Answers by Language