Skip to content

Instantly share code, notes, and snippets.

@ayberkanilatsiz
Created October 11, 2017 10:51
Show Gist options
  • Save ayberkanilatsiz/8e2d89f9a3ed0d8253778c68cf7f731c to your computer and use it in GitHub Desktop.
Save ayberkanilatsiz/8e2d89f9a3ed0d8253778c68cf7f731c to your computer and use it in GitHub Desktop.
socket handlers
onReceivedMessage(mes){
const arrMes = [{...mes.messages}];
this.setState((previousState) => ({
messages: GiftedChat.append(previousState.messages, arrMes),
}));
}
onSend(messages){
const mes = messages[0];
const { username } = this.state;
mes['username'] = username;
this.socket.emit('messages',mes)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment