docbrown/app/javascript/chat/compose.jsx
2019-04-16 17:28:19 -04:00

36 lines
905 B
JavaScript

import { h, Component } from 'preact';
import PropTypes from 'prop-types';
export default class Chat extends Component {
static propTypes = {
handleKeyDown: PropTypes.func.isRequired,
handleSubmitOnClick: PropTypes.func.isRequired,
activeChannelId: PropTypes.number,
};
shouldComponentUpdate(nextProps) {
return this.props.activeChannelId != nextProps.activeChannelId;
}
render() {
const { handleSubmitOnClick, handleKeyDown } = this.props;
return (
<div className="messagecomposer">
<textarea
className="messagecomposer__input"
id="messageform"
placeholder="Message goes here"
onKeyDown={handleKeyDown}
maxLength="1000"
/>
<button
className="messagecomposer__submit"
onClick={handleSubmitOnClick}
>
SEND
</button>
</div>
);
}
}