Created
January 28, 2022 08:57
-
-
Save iamparthaonline/e30bd2d524f768fba4b31628070c5e9c 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 UncontrolledComponent extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.inputRef = React.createRef(); | |
| } | |
| render() { | |
| return ( | |
| <form | |
| onSubmit={(event) => { | |
| event.preventDefault(); | |
| console.log("Input value - ", this.inputRef.current.value); | |
| }} | |
| > | |
| <div> | |
| <label>Uncontrolled input </label> | |
| <input type="date" name="data" id="date-input" ref={this.inputRef} /> | |
| </div> | |
| <button type="submit">Submit</button> | |
| </form> | |
| ); | |
| } | |
| } | |
| export default UncontrolledComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment