Skip to content

Instantly share code, notes, and snippets.

@khola khola/snip
Created Apr 12, 2019

Embed
What would you like to do?
import React, { Component } from "react";
class App extends Component {
state = { messages: [], input: "" };
onInput = e => {
this.setState({ input: e.target.value });
};
onSubmit = e => {
e.preventDefault();
//the real submit action code here
this.setState({ input: "" });
};
render() {
const { messages, input } = this.state;
return (
<div>
<hr />
<input type="text" value={input} onChange={this.onInput} />
<button onClick={this.onSubmit}>Submit</button>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.