Skip to content

Instantly share code, notes, and snippets.

@r1ckhenry
Created May 8, 2019 07:42
Show Gist options
  • Save r1ckhenry/461289169ea63ecbcb022ae48b1340d0 to your computer and use it in GitHub Desktop.
Save r1ckhenry/461289169ea63ecbcb022ae48b1340d0 to your computer and use it in GitHub Desktop.
Number Input React Component
class NumberInput extends Component {
state = {
value: ""
};
handleChange = e => {
this.setState({ value: e.target.value });
};
render() {
const { value } = this.state;
return (
<div>
<label htmlFor="numInput">Please enter number:</label>
<input
onChange={this.handleChange}
id="numInput"
type="number"
value={value}
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment