0
我想设置一个项的状态,然后使用新的状态,这是传递给我的组件的道具,但它不会出现要及时设置状态返回null阵营本地国有
constructor (props) {
super(props)
this.cartFirebase = firebaseApp.database().ref('carts')
this.cartFirebase.child(DeviceInfo.getUniqueID() + '/items').push({
item: this.props.data.name,
qty: 1
}).then((snap) => {
this.state = {
cartKey: snap.key
}
})
}
组件
<AddToCartRow item={this.props.data.sizes} option='size' key={this.state.cartKey}/>