Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@theneonproject/react-chat-window
Advanced tools
react-chat-window
provides an intercom-like chat window that can be included easily in any project for free. It provides no messaging facilities, only the view component.
$ npm install react-chat-window
import React, {Component} from 'react'
import {Launcher} from 'react-chat-window'
class Demo extends Component {
constructor() {
super();
this.state = {
messageList: []
};
}
_onMessageWasSent(message) {
this.setState({
messageList: [...this.state.messageList, message]
})
}
_sendMessage(text) {
if (text.length > 0) {
this.setState({
messageList: [...this.state.messageList, {
author: 'them',
type: 'text',
data: { text }
}]
})
}
}
render() {
return (<div>
<Launcher
agentProfile={{
teamName: 'react-chat-window',
imageUrl: 'https://a.slack-edge.com/66f9/img/avatars-teams/ava_0001-34.png'
}}
onMessageWasSent={this._onMessageWasSent.bind(this)}
messageList={this.state.messageList}
showEmoji
/>
</div>)
}
}
For more detailed examples see the demo folder.
Launcher
is the only component needed to use react-chat-window. It will react dynamically to changes in messages. All new messages must be added via a change in props as shown in the example.
Launcher props:
prop | type | required | description |
---|---|---|---|
agentProfile | object | yes | Represents your product or service's customer service agent. Fields: imageUrl (string), teamName (string). |
handleClick | function | yes | Intercept the click event on the launcher. No argument sent when function is called. |
isOpen | boolean | yes | Force the open/close state of the chat window. If this is not set, it will open and close when clicked. |
messageList | [message] | yes | An array of message objects to be rendered as a conversation. |
mute | boolean | no | Don't play sound for incoming messages. Defaults to false . |
newMessagesCount | number | no | The number of new messages. If greater than 0, this number will be displayed in a badge on the launcher. Defaults to 0 . |
onFilesSelected | function(fileList) | no | Called after file has been selected from dialogue in chat window. |
onMessageWasSent | function(message) | yes | Called when a message is sent, with a message object as an argument. |
showEmoji | boolean | no | Whether or not to show the emoji button in the input bar. Defaults to true . |
Message objects are rendered differently depending on their type. Currently, only text, file, and emoji types are supported. Each message object has an author
field which can have the value 'me' or 'them'.
{
author: 'them',
type: 'text',
data: {
text: 'some text'
}
}
{
author: 'me',
type: 'emoji',
data: {
code: 'someCode'
}
}
{
author: 'me',
type: 'file',
data: {
url: 'somefile.mp3',
fileName: 'Any old name'
}
}
{
author: 'them',
type: 'text',
data: {
text: 'some text'
},
quickReplies: [
{
author: 'me',
type: 'text',
data: { text: 'A quick reply' }
},
{
author: 'me',
type: 'emoji',
data: { emoji: '🤓' }
}
]
}
Look like this:
{
imageUrl: 'https://somewhere.on/the_web.png',
teamName: 'Da best'
}
If you're using react-chat-window in a product I'd love to see what you're making! Email me at dylan@kingofthestack.com
FAQs
react-chat-window React component
We found that @theneonproject/react-chat-window demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.