Last active
March 11, 2019 13:01
-
-
Save codingnninja/87989b125b9676558d6f648e29b09cf8 to your computer and use it in GitHub Desktop.
Signup ( 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 SignUp extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handleChange = this.handleChange.bind(this); | |
this.handleSignUp = this.handleSignUp.bind(this); | |
this.state = {username: ''}; | |
} | |
render() { | |
return ( | |
<Dialog title="Signup now" | |
message="Get superpowers for free."> | |
<input value={this.state.username} | |
onChange={this.handleChange} /> | |
<button onClick={this.handleSignUp}> | |
Sign Me Up! | |
</button> | |
</Dialog> | |
); | |
} | |
handleChange(e) { | |
this.setState({username: e.target.value}); | |
} | |
handleSignUp() { | |
alert(`Welcome aboard, ${this.state.username}!`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment