Recommend react-native-easy-app open source library, it can make us more convenient to use AsyncStorage.
import { XStorage } from 'react-native-easy-app'; import { AsyncStorage } from 'react-native'; const initCallback = () => { // From now on, you can write or read the variables in RNStorage synchronously // equal to [console.log(await AsyncStorage.getItem('isShow'))] console.log(RNStorage.isShow); // equal to [ await AsyncStorage.setItem('token',TOKEN1343DN23IDD3PJ2DBF3==') ] RNStorage.token = 'TOKEN1343DN23IDD3PJ2DBF3=='; // equal to [ await AsyncStorage.setItem('userInfo',JSON.stringify({ name:'rufeng', age:30})) ] RNStorage.userInfo = {name: 'rufeng', age: 30}; }; XStorage.initStorage(RNStorage, AsyncStorage, initCallback);
github: github.com/chende008/react-native-...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Recommend react-native-easy-app open source library, it can make us more convenient to use AsyncStorage.
github: github.com/chende008/react-native-...