Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #store #array #local #storage
ADD COMMENT
Topic
Name
7+6 =