Skip to content

Instantly share code, notes, and snippets.

@codingnninja
Last active March 11, 2019 13:01
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 codingnninja/87989b125b9676558d6f648e29b09cf8 to your computer and use it in GitHub Desktop.
Save codingnninja/87989b125b9676558d6f648e29b09cf8 to your computer and use it in GitHub Desktop.
Signup ( A class component)
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