Last active
January 28, 2022 07:50
-
-
Save iamparthaonline/bfffd6ac88cc701257c407660bd87c80 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
| import React, { Component } from "react"; | |
| class ControlledComponent extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| text: "" | |
| }; | |
| } | |
| render() { | |
| return ( | |
| <div> | |
| <form> | |
| <div> | |
| <label>Controlled Input </label> | |
| <input | |
| type="number" | |
| name="sentence" | |
| onChange={(event) => { | |
| this.setState({ | |
| text: event.target.value, | |
| }); | |
| }} | |
| value={this.state.text} | |
| /> | |
| </div> | |
| <button type="submit">Submit</button> | |
| </form> | |
| </div> | |
| ); | |
| } | |
| } | |
| export default ControlledComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment