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

react-chat-awesome

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chat-awesome

Configurable react chat widget

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

react-chat-awesome

Fully configurable and customizable chat component for your React applications.

Advantages

  • 100% Customizable
  • Props for styles customization
  • Lightweight (only react and prop-types as deps)
  • Message validation included
  • Backend agnostic
  • In active development

Comming in new versions:

  • emoji picker
  • sending files and images

[Demo] Coming soon...

Table of Contents

  • Installation
  • Example
  • API

Installation

The package can be installed via NPM:

npm install react-chat-awesome --save

Or YARN:

yarn add react-chat-awesome --save

Example

import React, { Component } from 'react'
import { ChatAwesome } from 'react-chat-awesome'

export default class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      history: []
    }

    this.sender = {
      id: 1
    }

    this.receiver = {
      id: 2,
      imageUrl: 'path/to/source'
    }
  }

  onSendMessageClick = (msgText) => {
    this.setState({ history: [...this.state.history, {
      id: +new Date(),
      msg: {
        type: 'text'
        text: msgText
      },
      userID: this.sender.id
    }]})
  }

  render() {
    return (
      <div>
        <ChatAwesome
          history={ this.state.history }
          sender={ this.sender }
          receiver={ this.receiver }
          onSendMessageClick={ this.onSendMessageClick }
        />
      </div>
    );
  }
}

API

ChatAwesome is the only component you need to import. * - required prop

ChatAwesome props:

proptypedescription
*senderobjectperson who interacts with the UI and types the message.
*receiverobjectperson who receives the messages and send responses to sender
historymessage[]array of messages
onSendMessageClickfunctioncallback function, executes when user send the message
onMessageChangefunctioncallback function, executes when user type something
onChatClosefunctioncallback on close button click
onChatOpenfunctioncallback on open button click
isOpenbooleanprogramatically close/open chat (default false)
showReceiverImageOnMessagebooleanset if image should be displayed near each receiver message
sendMessageIconstringurl for alternative icon
wrapperStylesobject
headerStylesobjectstyles for chat header
sendButtonStylesobjectstyles for send button(not icon)
bodyStylesobjectstyles for messages wrapper
footerStylesobjectstyles for wrapper of the input field and chat button
inputStylesobjectstyles for input field
closedChatStylesobjectstyles for closed chat button
headerNameStylesobjectstyles for receiver name at the header

Interfaces

Sender

{
  id: number | string; // required
}

Receiver

{
  id: number | string; // required 
  imageUrl: string;
}

Message

{
  id: number | string;
  userID: number | string;
  msg: {
    type: string;
    text: string;
  }
}

Keywords

FAQs

Package last updated on 19 Jul 2018

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