Created
March 11, 2019 13:07
-
-
Save codingnninja/3e47b74d7ac9cb288c965966ef0bd549 to your computer and use it in GitHub Desktop.
Login (A class component)
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 React.Component { | |
constructor(props) { | |
super(props); | |
this.handleChange = this.handleChange.bind(this); | |
this.handleLogIn = this.handleLogIn.bind(this); | |
this.state = {username: ''}; | |
} | |
render() { | |
return ( | |
<Dialog title="Login now" | |
message="Get more superpowers for free"> | |
<input value={this.state.username} | |
onChange={this.handleChange} /> | |
<button onClick={this.handleLogIn}> | |
Log Me In! | |
</button> | |
</Dialog> | |
); | |
} | |
handleChange(e) { | |
this.setState({username: e.target.value}); | |
} | |
handleLogIn() { | |
alert(`Welcome back, ${this.state.username}!`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment