Skip to content

Instantly share code, notes, and snippets.

@ajaykumar97
Created December 19, 2019 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajaykumar97/cdabbab4a3a38dcf47538f474fc062cf to your computer and use it in GitHub Desktop.
Save ajaykumar97/cdabbab4a3a38dcf47538f474fc062cf to your computer and use it in GitHub Desktop.
Gifted Chat Small Jerk Issue
import React from 'react';
import { GiftedChat } from 'react-native-gifted-chat';
export default class Example extends React.Component {
state = {
messages: [],
};
componentDidMount() {
this.setState({
messages: [
{
_id: 1,
text: 'Hello developer',
createdAt: new Date(),
user: {
_id: 2,
name: 'React Native',
avatar: 'https://placeimg.com/140/140/any',
},
},
],
});
}
onSend(messages = []) {
this.setState(previousState => ({
messages: GiftedChat.append(previousState.messages, messages),
}));
}
render() {
return (
<GiftedChat
messages={this.state.messages}
onSend={messages => this.onSend(messages)}
user={{
_id: 1,
}}
/>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment