[英]How to set array of object inside async storage in react native
I am trying to set array of object inside async storage but I did not set it.我正在尝试在异步存储中设置 object 数组,但我没有设置它。 Could someone please help me how to achieve this.
有人可以帮助我如何实现这一目标。 Thanks
谢谢
Code代码
let joined = this.state.product.concat(product);
this.props.setNotification(joined);
AsyncStorage.setItem("count", joined);
The easiest way is to stringify the array and store it最简单的方法是将数组字符串化并存储
AsyncStorage.setItem('count', JSON.stringify(joined));
You will have to parse the string when you retrieve it检索字符串时必须对其进行解析
const storedArray = await AsyncStorage.getItem('count');
const array = JSON.parse(storedArray)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.