Created
May 8, 2019 07:42
-
-
Save r1ckhenry/461289169ea63ecbcb022ae48b1340d0 to your computer and use it in GitHub Desktop.
Number Input React 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 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