Skip to content

Instantly share code, notes, and snippets.

@gaperton
Last active December 1, 2017 04:06
Show Gist options
  • Save gaperton/16504f679e7ad00c671a40065fdf4187 to your computer and use it in GitHub Desktop.
Save gaperton/16504f679e7ad00c671a40065fdf4187 to your computer and use it in GitHub Desktop.
@define class UserForm extends React.Component {
static state = {
name : '',
email : '',
isActive : true
}
onSubmit = () => { /* TBD */ };
onCancel = () => { /* TBD */ };
render(){
// Link the state...
const { name, email, isActive } = this.linkAll();
return (
<form onSubmit={ this.onSubmit }>
<label>
Name: <input type="text" { ...name.props }/>
</label>
<label>
Email: <input type="text" { ...email.props }/>
</label>
<label>
Is active: <input type="checkbox" { ...isActive.props }/>
</label>
<button type="submit">Save</button>
<button type="button" onClick={ this.onCancel }>
Clear
</button>
</form>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment