【发布时间】:2019-10-07 12:08:21
【问题描述】:
ComponentWillMount 已被重命名和弃用,不建议使用
constructor(props) {
super(props);
this.state = {
cartItems: []
};}
componentWillMount() {
AsyncStorage.getItem("CART", (err, res) => {
if (!res) this.setState({ cartItems: [] });
else this.setState({ cartItems: JSON.parse(res) });
});}
在渲染之前我应该怎么做才能获取 cartItems ??
【问题讨论】:
标签: reactjs react-native asyncstorage