The Messages Field
Now, we will restructure our Messages component to use objects in of arrays.
We'll cover the following...
We currently have the messages as an array with message objects.
Press + to interact
messages: [{messageTo: 'contact1',text: "Hello"},{messageTo: 'contact2',text: "Hey!"}]
We will now define a more appropriate shape for the message objects. A message object will be represented by the message object below:
Press + to interact
{text,is_user_msg};
The text is the displayed text within the chat bubble. However, is_user_msg will be a Boolean - true or false. This is important to differentiate if a message is from a contact or the default app user.
Looking ...