Skip to content

Instantly share code, notes, and snippets.

@iamparthaonline
Created January 28, 2022 08:57
Show Gist options
  • Select an option

  • Save iamparthaonline/e30bd2d524f768fba4b31628070c5e9c to your computer and use it in GitHub Desktop.

Select an option

Save iamparthaonline/e30bd2d524f768fba4b31628070c5e9c to your computer and use it in GitHub Desktop.
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