【发布时间】:2021-08-07 22:03:11
【问题描述】:
我正在尝试访问与设置它的文件不同的文件中的 react-native 异步存储。在设置它的同一个文件中,我能够获得该值。但在不同的文件中,我将“false”作为值。 任何帮助将不胜感激。
import AsyncStorage from '@react-native-async-storage/async-storage';
const getData = async () => {
console.log("fetching data from asyncstorage")
try {
const value = await AsyncStorage.getItem('userToken'); << retuning false
if(value !== null) {
console.log(value);
token.token=value;
}
} catch(e) {
console.log(e);
}
}
const callfunction=()=>{
getData();
}
【问题讨论】: