AsyncStorageを使用してデータを取得しようとしています。私が自分のアクションクリエータを呼び出すたびにrequestDataと渡されたデータのコンソールを実行すると、私は以下のようになります。私はgetItemの2つのバージョンを持っています。両方のバージョンでプロパティフィールドの無駄な値を取得します。プロパティ値は読み取り可能である必要があります。AsyncStorage.getItem in reactネイティブが期待どおりに動作しない
{"fromDate": "20160601"、 "toDate": "20160701"、 "property":{"_ 40":0、 "_ 55":null、 "_72":ヌル}、 "URL": "/ ABC/ABC/XYZ"}
async getItem(item) {
let response = await AsyncStorage.getItem(item);
let responseJson = await JSON.stringify(response);
return responseJson;
}
async getItem(item) {
try {
const value = AsyncStorage.getItem(item).then((value) => { console.log("inside componentWillMount method call and value is "+value);
this.setState({'assetIdList': value});
}).then(res => {
return res;
});
console.log("----------------------------value--------------------------------------"+value);
return value;
} catch (error) {
// Handle errors here
console.log("error is "+error);
}
}
componentWillMount() {
requestData({
fromDate: '20160601',
toDate: '20160701',
assetId: this.getItem(cmn.settings.property),
url: '/abc/abc/xyz'
});
}