SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from "react";
  2.  
  3. class Form extends Component {
  4.   state = {
  5.     username: "",
  6.     comment: ""
  7.   };
  8.   handleUsernameChange = event => {
  9.     this.setState({
  10.       username: event.target.value
  11.     });
  12.   };
  13.  
  14.   handleCommentChange = event => {
  15.     this.setState({
  16.       comment: event.target.value
  17.     });
  18.   };
  19.  
  20.   handleSubmit = event => {
  21.     event.preventDefault();
  22.   };
  23.   render() {
  24.     return (
  25.       <form onSubmit={this.handleSubmit}>
  26.         <div>
  27.           <label>Your Name</label>
  28.           <input
  29.             type="text"
  30.             value={this.state.username}
  31.             onChange={this.handleUsernameChange}
  32.           />
  33.           <div>
  34.             <label>Comment</label>
  35.             <textarea
  36.               value={this.state.comment}
  37.               onChange={this.handleCommentChange}
  38.             ></textarea>
  39.           </div>
  40.           <button type="submit">Submit</button>
  41.         </div>
  42.       </form>
  43.     );
  44.   }
  45. }
  46.  
  47. export default Form;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top