@nju33/react-slack
v0.1.33
Published
[![@nju33/react-slack](https://img.shields.io/npm/v/@nju33/react-slack.svg)](https://www.npmjs.com/package/@nju33/react-slack) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/) [![code style: prettier](https:
Downloads
2
Readme
react-slack
Install
yarn add @nju33/react-slack
yarn add react @types/react
Slack's scope
Please approve the following.
- channels:history
- channels:read
- users:read (if you use user info)
Example
import {MessageHistory, SlackUser} from '@nju33/react-slack';
// class MessageHistory ... {
// static defaultProps = {
// historyCount: 100,
// messageFilter(messages: SlackMessage[]): SlackMessage[] {
// return messages.filter(message => {
// return message.type === 'message' && message.subtype === undefined;
// });
// },
// userInfo: true
// };
<MessageHistory
token="xoxp-xxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
channelName="foo"
historyCount={100} // Number to process at one time
userInfo={true} // Whether to use detailed user information
>
{({messages, getLatest, next}) => {
const messageElements = messages.map(message => {
const user = message.user as SlackUser;
return (
<li key={message.ts}>
<div>{user.name}</div>
<div>{message.text}</div>
</li>
);
});
return (
<div>
<ul>{messageElements}</ul>
<div>
<span onClick={getLatest}>getLatest</span>
<span onClick={next}>next</span>
</div>
</div>
);
}}
</MessageHistory>;