Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-gifted-chat

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-gifted-chat

The most complete chat UI for React Native

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41K
decreased by-1.49%
Maintainers
1
Weekly downloads
 
Created
Source

Gifted Chat

The most complete chat UI for React Native (formerly known as Gifted Messenger)

Installation

npm install react-native-gifted-chat --save

Android installation

Add windowSoftInputMode in your Android Manifest android/app/src/main/AndroidManifest.xml

<!-- ... -->
  android:label="@string/app_name"
  android:windowSoftInputMode="adjustResize" // <!-- add this -->
  android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<!-- ... -->

Example

import React, { Component } from 'react';
import { GiftedChat } from 'react-native-gifted-chat';

class Example extends Component {
  constructor(props) {
    super(props);
    this.state = {messages: []};
    this.onSend = this.onSend.bind(this);
  }
  componentWillMount() {
    this.setState({
      messages: [
        {
          _id: 1,
          text: 'Hello developer',
          createdAt: new Date(Date.UTC(2016, 7, 30, 17, 20, 0)),
          user: {
            _id: 2,
            name: 'React Native',
            avatar: 'https://facebook.github.io/react/img/logo_og.png',
          },
        },
      ],
    });
  }
  onSend(messages = []) {
    this.setState((previousState) => {
      return {
        messages: GiftedChat.append(previousState.messages, messages),
      };
    });
  }
  render() {
    return (
      <GiftedChat
        messages={this.state.messages}
        onSend={this.onSend}
        user={{
          _id: 1,
        }}
      />
    );
  }
}

Advanced example

See example/App.js

Message object

{
  _id: 1,
  text: 'My message',
  createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
  user: {
    _id: 2,
    name: 'React Native',
    avatar: 'https://facebook.github.io/react/img/logo_og.png',
  },
  image: 'https://facebook.github.io/react/img/logo_og.png',
  // custom params
}

Props

  • messages (Array) - messages to display
  • user (Object) - user sending the messages {_id, name, avatar}
  • onSend (Function) - function to call when sending a message
  • locale (String) - localize the dates
  • isAnimated (Bool) - animates the view when the keyboard appears
  • loadEarlier (Bool) - enables the load earlier message button
  • onLoadEarlier (Function) - function to call when loading earlier messages
  • renderLoading (Function) - render a loading view when initializing
  • renderLoadEarlier (Function) - render the load earlier button
  • renderAvatar (Function) - renders the message avatar
  • renderBubble (Function) - render the message bubble
  • renderMessage (Function) - render the message container
  • renderMessageText (Function) - render the message text
  • renderMessageImage (Function) - render the message image
  • renderCustomView (Function) - render a custom view inside the bubble
  • renderDay (Function) - render the day above a message
  • renderTime (Function) - render the message time
  • renderInputToolbar (Function) - render the composer container
  • renderActions (Function) - renders an action button on the left of the message composer
  • renderComposer (Function) - render the text input message composer
  • renderSend (Function) - render the send button
  • renderAccessory (Function) - renders a second line of actions below the message composer

Features

  • Custom styles
  • Custom actions
  • Multiline TextInput
  • Load earlier messages
  • Avatar as initials
  • Touchable links using react-native-parsed-text
  • Localized dates
  • Copy text message to clipboard

LICENSE

Feel free to ask me questions on Twitter @FaridSafi !

Keywords

FAQs

Package last updated on 30 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc