[英]How to put my api body in messages for gifted chat
can anyone tell me?谁能告诉我? I get an array of messages, through api, it contains id, body, owner name "messages": [ { "id": "1", "createdAt": "2019-10-23T12:58:22.933Z", "body": "Hello", }, .....
我通过 api 收到一组消息,它包含 id、body、所有者名称身体”:“你好”,},......
How can I write it as an array for giftedchat, what would it be "messages": [ { "_id": "1", "createdAt": "2019-10-23T12:58:22.933Z", "text": "Hello", }, .....我怎样才能把它写成giftedchat的数组,它是什么“消息”:[{“_id”:“1”,“createdAt”:“2019-10-23T12:58:22.933Z”,“文本”: “你好”, }, .....
And there are 10 messages, that is, how to iterate over to write values from one array to another并且有 10 条消息,即如何迭代以将值从一个数组写入另一个数组
Just for a flatlist, there goes render and selects, name: item.ownername, is there something similar that could be used for messages in gifted chat?只是对于一个平面列表,有渲染和选择,名称:item.ownername,有没有类似的东西可以用于天才聊天中的消息?
You should map your array to get the same format as needed for GiftedChat您应该 map 您的阵列以获得与 GiftedChat 所需的相同格式
const newArray = messages.map(message => ({ _id: message.id, createdAt: message.createdAt, text: message.body, user: { _id: //user_id, name: //username } }))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.