js-waku/web-chat/src/MessageInput.tsx

40 lines
854 B
TypeScript
Raw Normal View History

2021-04-19 13:33:23 +10:00
import React, { ChangeEvent } from 'react';
import { TextField } from '@material-ui/core';
interface Props {
messageHandler: (msg: string) => void;
}
interface State {
inputText: string;
}
export default class MessageInput extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
inputText: ''
};
}
messageHandler(event: ChangeEvent<HTMLInputElement>) {
this.props.messageHandler(event.target.value);
}
render() {
return (
<TextField variant='outlined'
2021-04-19 14:54:39 +10:00
label='Send a message'
fullWidth
style={{ margin: 8 }}
margin="normal"
InputLabelProps={{
shrink: true,
}}
onChange={this.messageHandler.bind(this)}
2021-04-19 13:33:23 +10:00
/>
);
}
}