Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   private saveData = async () => {
  2.     await AsyncStorage.setItem(
  3.       '@appdemo:tasks',
  4.       'erick',
  5.       JSON.stringify([{ key: 1, text: 'uno' }, { key: 2, text: 'dos' }])
  6.     )
  7.       .then(valor => {
  8.         console.log(valor);
  9.       })
  10.       .catch(error => {
  11.         console.log(error);
  12.       });
  13.   };
  14.   private recoverData = async () => {
  15.     await AsyncStorage.getItem('@appdemo:tasks')
  16.       .then(valor => {
  17.         console.log(valor);
  18.  
  19.         if (valor !== null) {
  20.           const newtask = JSON.parse(valor);
  21.           this.setState({ tareas: newtask });
  22.         }
  23.       })
  24.       .catch(error => {
  25.         console.log(error);
  26.       });
  27.   };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement