Created
          December 19, 2019 09:17 
        
      - 
      
- 
        Save ajaykumar97/cdabbab4a3a38dcf47538f474fc062cf to your computer and use it in GitHub Desktop. 
    Gifted Chat Small Jerk Issue
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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