Skip to content

Instantly share code, notes, and snippets.

@joelbarbosa
Created November 17, 2017 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelbarbosa/2ca27b87c07c035fe2cf81eba92a7f5c to your computer and use it in GitHub Desktop.
Save joelbarbosa/2ca27b87c07c035fe2cf81eba92a7f5c to your computer and use it in GitHub Desktop.
Uncontrolled Components
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