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}/>