Skip to content

Instantly share code, notes, and snippets.

@luandevpro
Last active March 27, 2018 04:56
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 luandevpro/78d7b6b3a24efb4d70d7ec8582fe6e2a to your computer and use it in GitHub Desktop.
Save luandevpro/78d7b6b3a24efb4d70d7ec8582fe6e2a to your computer and use it in GitHub Desktop.
React
import React, { Component } from 'react';
class Input extends Component {
constructor() {
super();
this.state = {
fullName: ''
}
}
handleFullNameChange = (e) => {
this.setState({
fullName: e.target.value
})
}
handleSubmit = (e) => {
e.preventDefault();
console.log(this.state.fullName)
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<label>Full Name</label>
<input
type="text"
value={this.state.fullName}
onChange={this.handleFullNameChange}
name="fullName" />
<input type="submit" value="Submit" />
</form>
</div>
);
}
}
export default Input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment