SOLVED: Cannot read property 'addMessage' of undefined

Hi all,
I’m using to send/receive messages.into chat page very similar to kitchensink messages page.
I’ve error Cannot read property ‘addMessage’ of undefined when receiving messages but only the second time I open the messages page.
Framework7Component object seems empty when entering the event callback the second time.
Framework7 version is 4.2.0

This is the code in the initPage:

app.on('chat_message', (data) => {
    text: data.message,
    type: 'received',
    avatar: data.avatar

First time I enter the page messages receiving is ok.
Then I go back with navbar back button.
Then re-enter the page and this time messages receiving isn’t working anymore with the error above.

Solved with
pageBeforeRemove: function (e, page) {
var self = this;
if (self.messagebar) {