Created
August 12, 2017 03:31
-
-
Save jslnriot/f1756fd4eb27180233216abf396f9099 to your computer and use it in GitHub Desktop.
This file contains 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
class MessageInput extends React.Component { | |
state = { | |
value: '', | |
} | |
onChange = (e) => { | |
this.setState({ | |
value: e.target.value, | |
}) | |
}; | |
handleSubmit = () => { | |
store.dispatch({ | |
type: 'ADD_MESSAGE', | |
message: this.state.value, | |
}); | |
this.ssetState({ | |
value: '', | |
}); | |
}; | |
render() { | |
return ( | |
<div className='ui input'> | |
<input | |
onChange={this.onChange} | |
value={this.state.value} | |
type='text' | |
/> | |
<button | |
onClick={this.handleSubmit} | |
className='ui primary button' | |
type='submit' | |
> | |
Submit | |
</button> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment