I am trying to set the state of an item then use the new state as a prop which is passed to my component but it doesn't appear to be setting the state in time
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
}
})
}
Component
<AddToCartRow item={this.props.data.sizes} option='size' key={this.state.cartKey}/>