Last active
August 25, 2016 16:50
-
-
Save Deiru2k/fa3cd1e8a3ec0539a8408742c3759581 to your computer and use it in GitHub Desktop.
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
class Login extends Component { | |
constructor() { | |
super(); | |
this.changeField = this.changeField.bind(this); | |
this.login = this.login.bind(this); | |
this.state = { | |
login: ``, | |
password: ``, | |
}; | |
} | |
changeField(field) { | |
return (event) => { | |
this.setState({ [field]: event.target.value }); | |
}; | |
} | |
login() { | |
const { login, password } = this.state; | |
myAjaxCall({ login, password }); | |
} | |
render() { | |
return ( | |
<form> | |
<input type="text" onChange={changeField("login")} value={this.state.login} /> | |
<input type="password" onChange={changeField("password")} value={this.state.password} /> | |
<button type="button" onClick={this.login} /> | |
</form> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment