Created
January 18, 2017 14:39
-
-
Save EQuimper/cfd276829a7ef9f78d0b698215380994 to your computer and use it in GitHub Desktop.
Using ref in functional component
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
function CustomForm ({handleSubmit}) { | |
let inputElement | |
return ( | |
<form onSubmit={() => handleSubmit(inputElement.value)}> | |
<input | |
type='text' | |
ref={(input) => inputElement = input} /> | |
<button type='submit'>Submit</button> | |
</form> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment