Skip to content

Instantly share code, notes, and snippets.

@zgotsch
Created May 4, 2019 00:45
Show Gist options
  • Save zgotsch/cc30d055f4e48000462fdefdc5fef9ad to your computer and use it in GitHub Desktop.
Save zgotsch/cc30d055f4e48000462fdefdc5fef9ad to your computer and use it in GitHub Desktop.
A simple form
class Form extends React.Component {
state = {name: ""};
handleNameChange = e => {
this.setState({
name: e.currentTarget.value
});
};
render() {
return (
<div>
Name:{" "}
<input
type="text"
value={this.state.name}
onChange={this.handleNameChange}
/>
<div
style={{
marginTop: "0.5em",
textAlign: "right"
}}
>
<button onClick={e => this.props.onSubmit(this.state)}>Submit</button>
</div>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment