I cannot pass a parent's state to its child component.
I've tried passing the whole parent's state to the child, however, the content of the state itself was undefined
.
Also, I've tried similarly by using props, but it did not work well either.
//parent.js
state = {
messages: [],
roomId: this.props.navigation.getParam('roomId')
}
renderImageAction = () => {
return <ImageAction roomId={this.state.roomId} />
}
return(<GiftedChat renderActions={this.renderImageAction}/>)
//child.js
DataBase.saveImage(this.props.roomId).then(alert('done'));
I expect that the state or the value will be passed to the child component, and there the value will be available.