我正在我的Android模拟器中运行此程序,但是在实际设备上却出现了同样的情况。该密钥不存在,但仍返回一些奇怪的承诺,如下所示。我很困惑!
准确执行文档中所说的内容:
https://github.com/react-native-community/react-native-async-storage/blob/master/docs/API.md
import AsyncStorage from '@react-native-community/async-storage';
getData = async () => {
try {
const value = await AsyncStorage.getItem("keydoesnotexist")
console.log(value)
if(value !== null) {
return value
}
} catch(e) {
console.error(e)
}
}
值记录为:
{"_40":0,"_65":0,"_55":null,"_72":null}
"@react-native-community/async-storage": "^1.2.4",