Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Expo/React native AsyncStorage.getItem()解析为null_Javascript_React Native_Expo - Fatal编程技术网

Javascript Expo/React native AsyncStorage.getItem()解析为null

Javascript Expo/React native AsyncStorage.getItem()解析为null,javascript,react-native,expo,Javascript,React Native,Expo,我正在世博会开发一个应用程序,面临一个非常简单的问题 在我的App.js中: AsyncStorage.setItem("test", "testVal").then((res) => { AsyncStorage.getItem("test", (value) => { console.log("VALUE: " + value); }); }); 上面的代码记录的是VALUE:null,而不是VALUE:test。对可能出现的问题有什么想法吗 (

我正在世博会开发一个应用程序,面临一个非常简单的问题

在我的App.js中:

AsyncStorage.setItem("test", "testVal").then((res) => {
    AsyncStorage.getItem("test", (value) => {
        console.log("VALUE: " + value);
    });
});
上面的代码记录的是
VALUE:null
,而不是
VALUE:test
。对可能出现的问题有什么想法吗


(使用EXPO版本3.17.21)

这是
getItem
签名:

static getItem(key: string, [callback]: ?(error: ?Error, result: ?string) => void): Promise
因此回调的第一个参数是
error
。尝试:

AsyncStorage.setItem("test", "testVal").then((res) => {
    AsyncStorage.getItem("test", (err, value) => {
        console.log("VALUE: " + value);
    });
})