AsyncStorage is a simple key-value pair storage solution for a react-native Application.
1.Set data
First import AsyncStorage into the component
import { AsyncStorage } from ‘react-native’;
then
let user={ loggedInUser:'0',
mobileNo:'8086502009',
name:'V Ajith',
token:'8f5rw2h7r0s62gex'}AsyncStorage.setItem( ‘user’, JSON.stringify(user) );
2.Fetch data
AsyncStorage.getItem('user').then(
userInfo => {console.log(userInfo)}).done();
3.Update Data
AsyncStorage.getItem('user')
.then(userInfo => {
let user= JSON.parse(userInfo);
user.name='Ajith',
AsyncStorage.setItem('user',JSON.stringify(user));
}).done();