Created
November 17, 2017 16:05
-
-
Save joelbarbosa/2ca27b87c07c035fe2cf81eba92a7f5c to your computer and use it in GitHub Desktop.
Uncontrolled Components
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
import React , { Component } from 'react'; | |
export default class ControlledComponent extends Component { | |
handleSubmit = event => { | |
const { name, idade } = event.target; | |
console.log(name.value, idade.value) | |
event.preventDefault() | |
} | |
render () { | |
return ( | |
<form onSubmit={this.handleSubmit}> | |
<input name="name" ref={input => this.input = input}/> | |
<input name="idade" ref={input => this.input = input}/> | |
<input type="submit" value="Submit" /> | |
</form> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment