Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setState((previousState) => {
return {
...previousState,
messages: GiftedChat.append(previousState.messages, messages),
};
});
// this.onReceive(); // for demo purpose
this.setState((previousState) => ({
messages: GiftedChat.append(previousState.messages, messages),
}));
}
this.setState((previousState) => {
return {
...previousState,
messages: GiftedChat.append(previousState.messages, {
_id: Math.round(Math.random() * 1000000),
text: 'Hodor',
createdAt: new Date(),
user: {
_id: 2,
name: 'Bot',
avatar: 'https://facebook.github.io/react/img/logo_og.png',
},
}),
};
});
}
this.setState(previousState => ({
messages: GiftedChat.append(previousState.messages, formattedMessage)
}));
}
function onSend(typedMessage) {
setMessages(GiftedChat.append(messages, typedMessage));
sendMessage({
variables: {
conversation: conversation._id,
user: user._id,
content: typedMessage[0].text,
},
});
}
this.setState(previousState => ({
messages: GiftedChat.append(previousState.messages, messages),
}));
this.setState((previousState) => ({
messages: GiftedChat.append(previousState.messages, messages),
}));
}
this.setState((previousState) => {
return {
messages: GiftedChat.append(previousState.messages, messages),
}
})
this.setState(previousState => {
return {
messages: GiftedChat.append(previousState.messages, Object.assign({}, messages[0], { isNew: true }))
};
});
this.setState((previousState) => {
return {
messages: GiftedChat.append(previousState.messages, messages),
};
});
}