Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement