Search
 
SCRIPT & CODE EXAMPLE
 

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
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: insert condition in a object javascript 
Javascript :: react redux actions must be plain objects 
Javascript :: node readline question 
Javascript :: how to create uuid in javascript 
Javascript :: RFC 3339 format js 
Javascript :: js sort string array 
Javascript :: vue timeout 
Javascript :: jquery trigger link click 
Javascript :: How to create $(document).ready() for vanilla JavaScript 
Javascript :: mongoose connect to URL of atlas 
Javascript :: Check if local storage is used or empty 
Javascript :: javascript redirect to another page 
Javascript :: window location redirect javascript 
Javascript :: Return A Random Number within a range of numbers 
Javascript :: while loop countdown javascript 
Javascript :: nodejs express api 
Javascript :: json-server 
Javascript :: workbox push notifications 
Javascript :: javascript add css file 
Javascript :: document get element by id style 
Javascript :: how to write img jsx 
Javascript :: localstorage save array 
Javascript :: image not showing js 
Javascript :: package json proxy 
Javascript :: avascript sleep 1 second 
Javascript :: javascript remove a specific item from an array 
Javascript :: Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 
Javascript :: access to xmlhttprequest at from origin http localhost:3000 has been blocked by cors policy 
Javascript :: javascript open new tab window 
Javascript :: iterate object keys javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =