如何在React Native中使用AsyncStorage正确获取Item? [英] How to properly getItem with AsyncStorage in React Native?
本文介绍了如何在React Native中使用AsyncStorage正确获取Item?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我当前的项目要求我在本地存储用户数据,因此我使用React Native本身的AsyncStorage.但是我在如何检索已经保存的数据时遇到了一些问题,但我总是会得到null,但是却以某种方式保存了数据.
My current project require me to store user data locally, So I use the AsyncStorage from react native itself. However I got some issues on how to retrieve already saved data I always get null but somehow the data is saved..
我总是
{_45:0,_81:0,_65:null,_54:null}
{ _45: 0, _81: 0, _65: null, _54: null }
这是我的代码,这是react native文档中的简单示例
and here's my code, which is the simple example from react native documentation
AsyncStorage.setItem('baru', 'this is new dude!!');
var b = AsyncStorage.getItem('baru');
console.log(b);
推荐答案
查看全文