Skip to content

Instantly share code, notes, and snippets.

@bookercodes
Last active June 4, 2018 16:13
Show Gist options
  • Save bookercodes/fc9047e451a5dfea0b6dc4952ffffe5f to your computer and use it in GitHub Desktop.
Save bookercodes/fc9047e451a5dfea0b6dc4952ffffe5f to your computer and use it in GitHub Desktop.
// ./src/SendMessageForm.js
import React, { Component } from 'react'
import { Button, TextInput } from 'react-desktop/macOs'
class SendMessageForm extends Component {
state = {
text: ''
}
onSubmit = e => {
e.preventDefault()
this.props.onSend(this.state.text)
this.setState({ text: '' })
}
onChange = e => {
this.setState({ text: e.target.value })
if (this.props.onChange) {
this.props.onChange()
}
}
render() {
return (
<div className="send-message-form-container">
<form onSubmit={this.onSubmit} className="send-message-form">
<TextInput
type="text"
onChange={this.onChange}
value={this.state.text}
className="message-input"
/>
<Button color="blue" type="submit">
Send
</Button>
</form>
</div>
)
}
}
export default SendMessageForm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment