Guest User

Untitled

a guest
Jul 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class ControlledInput extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. input: ''
  6. };
  7. // change code below this line
  8. this.handleChange = this.handleChange.bind(this);
  9. // change code above this line
  10. }
  11. // change code below this line
  12. handleChange(event){
  13. this.setState({input: event.target.value});
  14. }
  15. // change code above this line
  16. render() {
  17. return (
  18. <div>
  19. { /* change code below this line */}
  20. <input onChange = {this.handleChange} type="text" name="input" value = {this.state.input} />
  21. { /* change code above this line */}
  22. <h4>Controlled Input:</h4>
  23. <p>{this.state.input}</p>
  24. </div>
  25. );
  26. }
  27. }
Add Comment
Please, Sign In to add comment