reactjssocket.iomobxmobx-state-tree

what is the issue mobx Error 'Reaction[observerobserved]?


Help me pls with this issue: I'am using mobx-state-tree + React + mobx + Socket.io ,i'm writing chat for project,and using for connection socket.io From server i get chats list and then put him to mobx-state-tree store using action,then i want get data from mobx-state-tree store and use map function for render elements But,i catch two errors This is my mobx-state-tree model for chat enter image description here

this is my code where i trying to maping data enter image description here

this is issue

enter image description here

But error "user" undefined is very stranger,because when i use console.log() for display data,array has this data and displayed in console

Okay,i find problem with Reaction[observerobserved] this happens because component which render chat list was not wrapped into observer function

But i'm still have problem with undefined props of array when i call map method on him


Solution

  • Resolve for |Reaction[observerobserved]" Need wrapped component into observer() function for subscribing on changes

    For second problem, with undefined prop:

    first solution wrong on the screen, because you try get undefined index in this case 'item.chat_users[index]", solution is use map for chat_users array to, and then render inner item for this data "item.chat_users.map(....)"