I am trying to communicating between component I have structure like
<div id=chat-box>
<div class="wrapper">
<div>
<chat-header></chat-header>
<message-container :chat="chat"></message-container>
<chat-compose @clicked="onClickChild"></chat-compose>
</div>
</div>
parent
methods: {
onClickChild (value) {
console.log('in top parent');
this.chat = value;
},
child 1
methods: {
startChat: function(event) {
this.$emit('clicked', new chat({
type: 'user',
message: this.input_value,
button: 'user',
metaInfo: 'user',
isBot: false,
}))
},
},
child 2
export default { name: 'messageContainer', props: ['chat'],
data: function() {
return {
chatSession: [],
}
},
method : {
updateData : function() {
console.log('called updatedata');
}
},
created: function () {
console.log(this.chat)
},
mounted: function () {
console.log(this.chat)
},
updated: function() {
console.log(this.chat)
}
}
Here on clickChild method is emitting the parent method which is updating the chat object but message-container component not getting the updated value it is showing default initialized value even not rendering again on data changes I tried created, mounted and updated method also to get the updated value these method are calling only once at the time of app initialization never calling again on data changes
Basically here are three component one is parent and other two are child so one child is updating the chat object and emitting to parent and parent passing same updated child to another child but the another child not getting re-render or getting the updated value so please help am I doing wrong or there are other way to achieve it.
chat
as a data property on your parent component? - Stephan-v