Last active
June 4, 2018 16:13
-
-
Save bookercodes/fc9047e451a5dfea0b6dc4952ffffe5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./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