text: import React from 'react';
  import { GiftedChat } from 'react-native-gifted-chat'; // 0.3.0
  
  import Fire from './Fire';
  
  type Props = {
    name?: string,
  };
  
  class Chat extends React.Component<Props> {
   
    static navigationOptions = ({ navigation }) => ({
      title: (navigation.state.params || {}).name || 'Chat!',
    });
  
    state = {
      messages: [],
    };
  
    get user() {
      return {
        name: this.props.navigation.state.params.name,
        _id: Fire.shared.uid,
      };
    }
  
    render() {
      return (
        <GiftedChat
          messages={this.state.messages}
          onSend={Fire.shared.send}
          user={this.user}
        />
      );
    }
  
    componentDidMount() {
      const { navigation } = this.props;
      const uid = navigation.getParam('uid');
      Fire.shared.groupId(uid);
      
      Fire.shared.on(message =>
        this.setState(previousState => ({
          messages: GiftedChat.append(previousState.messages, message),
        }))
      );
    }
    componentWillUnmount() {
      Fire.shared.off();
    }
  }
  
  export default Chat;
  