Created
March 31, 2020 10:39
-
-
Save abdelfattah-atef94/0074b39feec94a8724786dd28f7c55b5 to your computer and use it in GitHub Desktop.
uncontrolled component example
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
import React, { useRef } from "react"; | |
export default function App() { | |
const inputRef = useRef(null); | |
const handleSubmitButton = () => { | |
alert(inputRef.current.value); | |
}; | |
return ( | |
<div className="App"> | |
<input type="text" ref={inputRef} /> | |
<input type="submit" value="submit" onClick={handleSubmitButton} /> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment