Last active
October 9, 2020 16:35
-
-
Save haldarmahesh/05144ff2acaa8add019dff0baec36550 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 MyFrom extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = {phoneNumber: ''}; | |
| this.handleChangePhoneNumber = this.handleChangePhoneNumber.bind(this); | |
| this.handleSubmit = this.handleSubmit.bind(this); | |
| } | |
| handleChangePhoneNumber(event) { | |
| this.setState({value: event.target.value}); | |
| } | |
| handleSubmit(event) { | |
| alert('Hi your phone Number is: ' + this.state.value); | |
| event.preventDefault(); | |
| } | |
| render() { | |
| return ( | |
| <form onSubmit={this.handleSubmit}> | |
| <label> | |
| Phone Number: | |
| <input type="text" value={this.state.value} onChange={this.handleChangePhoneNumber} /> | |
| </label> | |
| <input type="submit" value="Submit" /> | |
| </form> | |
| ); | |
| } | |
| } |
Hi, there is a typo in the class name MyFrom > MyForm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this.setState({phoneNumber: event.target.value});
value={this.state.phoneNumber}